操作系统:RHEL 6.5
相关软件包:百度网盘 密码:bty7
本机系统镜像挂载至/mnt/cdrom/ (安装依赖包时使用)
解压mysql文件至/opt/
tar zxvf mysql-5.5.24.tar.gz -C /opt/
yum install gcc gcc-c++ make cmake -y
#进入系统镜像Packages目录下,安装三个依赖包
cd /mnt/cdrom/Packages
rpm -ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
rpm -ivh bison-2.4.1-5.el6.x86_64.rpm
rpm -ivh libaio-devel-0.3.107-10.el6.x86_64.rpm
groupadd mysql
useradd -g mysql mysql -s /sbin/nologin
mkdir -p /usr/local/mysql
5.进入mysql安装文件目录下
cd /opt/mysql-5.5.24
5.1 配置
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DMYSQL_DATADIR=/home/mysql
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
5.2 编译并安装软件
make && make install
如果报错,清空缓存文件-如果正常可忽略
find -name CMakeCache.txt
rm -f ./CMakeCache.txt
chown -R mysql.mysql /usr/local/mysql
vim /etc/profile
#在最后一行加入
PATH=$PATH:/usr/local/mysql/bin/
:wq! #保存退出
source /etc/profile
cd /opt/mysql-5.5.24/
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
#将mysqld服务添加进系统服务中,并设置init3、init5中开机自启动
chkconfig --add /etc/init.d/mysqld
chkconfig --level 35 mysqld on
/usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql
12.建立软链接文件
ln -s /var/lib/mysql/mysql.sock /home/mysql/mysql.sock # 直接建立软连接
vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/home/mysql
service mysqld start
netstat -ntap | grep 3306
mysql>show databases;
至此,Mysql服务已经部署完毕,请见下一章部署PHP服务。
原文地址:http://blog.51cto.com/10316297/2114719