MySQL5.6之后只能用cmake编译,因此现写关于mysql5.6的安装编译方法。
关于cmake安装编译,详见http://thankinglove.blog.51cto.com/2311485/1791792
#!/bin/bash #install_mysql-5.6.21.tar.gz cat /etc/passwd | grep "^mysql:" if [ $? -ne 0 ] then groupadd mysql fi cat /etc/passwd | grep "^mysql:" if [ $? -ne 0 ] then useradd -g mysql mysql -s /usr/sbin/nologin fi //创建mysql目录及数据目录 mkdir -p /usr/local/mysql mkdir -p /usr/local/mysql/data //更改所有者 chown -R mysql:mysql /usr/local/mysql //源码包放在/usr/local/src目录里 cd /usr/local/src tar xzvf mysql-5.6.21.tar.gz cd mysql-5.6.21 cmake -DCMAKE_INSTALl_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci make make install cp /usr/local/mysql/support-files/my-default.cnf /usr/local/mysql/my.cnf //初始化数据库 /usr/local/mysql/scripts/mysql_install_db --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --user=mysql //拷贝启动脚本 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql if [ -e /etc/my.cnf ] then mv /etc/my.cnf /etc/my.cnf.bak fi chkconfig --add mysql chkconfig mysql on
安装完成后启动mysql
service mysql start //查看mysql是否启动成功 netstat -tnlp | grep ":3306" ps aux | grep mysql