安装编译工具
[root@cce63 ~]#yum install -y cmake
创建运行用户
[root@cce63 ~]#tar xvf /root/lnmp/mysql-5.5.30.tar.gz -C .
[root@cce63 ~]#useradd -s /sbin/nologin mysql
编辑参数
[root@cce63 mysql-5.6.20]#cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DWITH_READLINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DMYSQL_USER=mysql
安装
make && make install
配置运行环境
[root@cce63 mysql-5.6.20]#chown mysql:mysql -R /usr/local/mysql/
[root@cce63 mysql-5.6.20]#cp support-files/my-large.cnf /etc/my.cnf
[root@cce63 mysql-5.6.20]#cp support-files/mysql.server /etc/init.d/mysqld
[root@cce63 mysql-5.6.20]#chmod +x /etc/init.d/mysqld
修改启动脚本参数
[root@cce63 ~]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
初始化数据库
[root@cce63 ~]#
/usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
开启启动
[root@cce63 ~]# chkconfig --add mysqld
添加客户端命令
[root@cce63 ~]# echo "PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile && source /etc/profile && source /etc/profile
设置mysql密码
[root@cce63 ~]# mysqladmin -u root password mysql
本文出自 “攻城狮” 博客,谢绝转载!