安装mysql
useradd -M -s /sbin/nologin mysql; yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake; tar zxvf mysql-5.6.25.tar.gz ;tar zxvf cmake-3.2.3.tar.gz cd cmake-3.2.3; ./bootstrap; gmake; make install ; cd ../mysql-5.6.25; cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql/;make ;make install chown -R mysql.mysql /opt/mysql cd /opt/mysql/scripts ./mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data cd /opt/mysql/support-files cp mysql.server /etc/rc.d/init.d/mysqld cp my-default.cnf /etc/my.cnf chkconfig --add mysqld chkconfig mysqld on chkconfig --level 35 mysqld on
配置文件修改
cat << EOF > /etc/my.cnf [mysqld] datadir=/opt/mysql/data basedir=/opt/mysql socket=/var/lib/mysql/mysql.sock user=mysql symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid EOF
设置开机自启
/etc/init.d/mysqld start /etc/init.d/mysqld restart
转载于:https://blog.51cto.com/wuxinglai/1672022