准备源码 代码: wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15.tar.gz/from/http://cdn.mysql.com/ tar -zxv -f mysql-5.6.15.tar.gz cd mysql-5.6.15 编译 代码: cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DMYSQL_USER=mysql \ -DMYSQL_TCP_PORT=3306 安装 代码: make make install ##########添加专门的mysql用户和组,控制权限####### groupadd mysql useradd -s /sbin/nologin -M -g mysql mysql cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf cd /usr/local/mysql scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data datadir=/usr/local/mysql/data chown -R mysql:mysql /usr/local/mysql chown -R mysql:mysql /usr/local/mysql/data chown -R mysql:mysql /usr/local/mysql/. chown -R mysql:mysql /usr/local/mysql/data/. ##########设置开机启动项########## cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql chmod 755 /etc/init.d/mysql cat > /etc/ld.so.conf.d/mysql.conf<<EOF /usr/local/mysql/lib/mysql /usr/local/lib EOF ldconfig ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql ln -s /usr/local/mysql/include/mysql /usr/include/mysql /etc/init.d/mysql start ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk #############设置mysql root用户的密码 /usr/local/mysql/bin/mysqladmin -u root password 你的密码 /etc/init.d/mysql restart /etc/init.d/mysql stop #################添加mysql为系统服务########### chkconfig --level 345 mysql on service mysql start