mkdir /var/lib/mysql_new
mysql_install_db --datadir=/var/lib/mysql_new --user=mysql
vi /etc/my.cnf 添加
[mysqld_multi]
mysqld=/usr/bin/mysqld_safe
mysqladmin=/usr/bin/mysqladmin
log=/var/log/mysqld_multi.log
user = multi_admin
password = multipass
[mysqld1]
datadir=/var/lib/mysql_new
socket=/var/lib/mysql_new/mysql.sock
port=4000
pid-file=/var/lib/mysql_new/mysql.pid
user=mysql
多实例启动
mysqld_multi start 1关闭MySQL多实例mysqld_multi stop 1查看MySQL端口启动状态netstat -ntlp | grep mysqld
查看MySQL实例进程ps -ef | grep mysql
通过port连接
mysql -u root -h 127.0.0.1 -P 4000 通过sock
mysql -u root -S /var/lib/mysql_new/mysql.sock -p
faq
my.cnf-[mysqld_multi]设置的user和password是用来关闭数据库实例的,根据配置中的用户名和密码授权该用户shutdown权限
mysql -S /var/lib/mysql_new/mysql.sock
mysql> grant shutdown on *.* to multi_admin@'localhost' identified by 'multipass';