mysql版本5.7
在my.cnf配置文件中增加下面的配置信息:
[mysqld_multi] #mysqld = /usr/local/mysql/bin/mysqld_safe mysqladmin = /usr/local/mysql/bin/mysqladmin user = root password = 123456 [mysqld3307] server-id=3307 port=3307 log-bin=mysql-bin log-error=/Users/zhja/mysql-cluster/master/mysqld.log tmpdir=/Users/zhja/mysql-cluster/master slow_query_log=on slow_query_log_file =/Users/zhja/mysql-cluster/master/mysql-slow.log long_query_time=1 socket=/Users/zhja/mysql-cluster/master/mysql_3307.sock pid-file=/Users/zhja/mysql-cluster/master/mysql.pid basedir=/Users/zhja/mysql-cluster/master datadir=/Users/zhja/mysql-cluster/master/data [mysqld3308] server-id=3308 port=3308 log-bin=mysql-bin log-error=/Users/zhja/mysql-cluster/slave/mysqld.log tmpdir=/Users/zhja/mysql-cluster/slave slow_query_log=on slow_query_log_file =/Users/zhja/mysql-cluster/slave/mysql-slow.log long_query_time=1 socket=/Users/zhja/mysql-cluster/slave/mysql_3308.sock pid-file=/Users/zhja/mysql-cluster/slave/mysql.pid basedir=/Users/zhja/mysql-cluster/slave datadir=/Users/zhja/mysql-cluster/slave/data read_only=1 执行和查看 killall mysqld mysqld_multi --defaults-extra-file=/etc/my.cnf start mysqld_multi --defaults-file=/etc/my.cnf report 登录实例 mysql -uroot -p -P3308 -h127.0.0.1