公司测试环境需求多个数据库实例,但是只分配一台MySQL机器,所以进行多实例部署。
cd /data/soft/package wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
rpm -qa |grep mysql |xargs -I '{}' rpm -e {} --nodeps
useradd mysql
tar xf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz -C /data/server/ cd /data/server mv mysql-5.7.30-linux-glibc2.12-x86_64/ mysql_65001
mkdir /data/dbdata/65001 -p mkdir /data/server/mysql_65001/etc -p mkdir /data/server/mysql_65001/logs -p mkdir /data/server/mysql_65001/mysql_bin/ -p chown -R mysql:mysql /data/server /data/dbdata
cd /data/server/mysql_65001 bin/mysqld --initialize --user=mysql --basedir=/data/server/mysql_4001 --datadir=/data/dbdata/65001
cd /data/server/mysql_65001 bin/mysql_ssl_rsa_setup --datadir=/data/dbdata/65001/
touch /data/server/mysql_65001/logs/mysql_65001.err
cd /data/server/mysql_65001 chown -R mysql:mysql /data/server /data/dbdata ./bin/mysqld_safe --defaults-file=/data/server/mysql_65001/etc/my.cnf --user=mysql & netstat -anpt |grep 65001
./bin/mysql -h127.0.0.1 -P65001 -p <初始化的密码> SET PASSWORD FOR 'root'@localhost=PASSWORD('新密码'); update mysql.user set host = '%' where user = 'root'; flush privileges;
echo "export PATH=/data/server/mysql_65001/bin:$PATH" >>/etc/profile source /etc/profile
/data/server/mysql_65002 /data/dbdata/65002 /data/server/mysql_65002/etc /data/server/mysql_65002/logs /data/server/mysql_65002/mysql_bin/ /data/server/mysql_65002/logs/mysql_65002.err