[[email protected]]# cd /opt/source
[[email protected]]#ls
mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
[[email protected]]# tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
[[email protected]]#ln -s /opt/source/mysql-5.7.21-linux-glibc2.12-x86_64 /usr/local/mysql
[[email protected]]#groupadd -g 500 mysql
[[email protected]]#useradd -r -g mysql -u 500 -s /bin/false mysql
[[email protected]]#cd /usr/local/
[[email protected]]#chown -R mysql.mysql mysql
创建3306端口实例
[[email protected]]#mkdir -p /data/mysql_3306/{data,logs,run,tmp}
[[email protected]]#cd /data/mysql_3306/logs
[[email protected]]#touch mysql_error.log
[[email protected]]#chown -R mysql.mysql /data/mysql_3306/
[[email protected]]#vi /data/mysql_3306/my.cnf
初始化mysql
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql_3306/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_3306/data
启动实例:
/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql_3306/my.cnf --user=mysql
创建3307端口实例
[[email protected]]#mkdir -p /data/mysql_3307/{data,logs,run,tmp}
[[email protected]]#cd /data/mysql_3307/logs
[[email protected]]#touch mysql_error.log
[[email protected]]#chown -R mysql.mysql /data/mysql_3307/
[[email protected]]#vi /data/mysql_3307/my.cnf
初始化mysql
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql_3307/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_3307/data
启动实例:
/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql_3307/my.cnf --user=mysql
原文地址:https://www.cnblogs.com/elontian/p/9499122.html