One MySQL server starts multiple ports: bitsCN.com
One MySQL server starts multiple ports
In the test Mysql multi-master and one slave server, that is, one slave server synchronizes multiple ports to different master databases. This document describes how to enable different ports.
Detailed steps:
1. first, copy the my. cnf configuration file. if you open several ports, copy the files and rename them.
For example:
Cp/etc/my. cnf/etc/my3306.cnf
Cp/etc/my. cnf/etc/my3307.cnf
Cp/etc/my. cnf/etc/my3308.cnf
2. modify the my_1.cnf my_2.cnf my_3.cnf file and change the default port 3306 to Port 3307 3308 3309.
For example:
[Client]
Port = 3308
Socket =/tmp/mysql3308.sock
Default-character-set = UTF
[Mysqld]
Port = 3308
Socket =/tmp/mysql3308.sock
Basedir =/usr/local/mysql
Datadir =/www/mysqldata8
3. create a database and specify a directory for storing data
Mkdir/www/mysqldata3306
Mkdir/www/mysqldata3307
Mkdir/www/mysqldata3308
4. initialize the database
/Usr/local/mysql/scripts/mysql_install_db -- datadir =/www/mysqldata3306/-- user = mysql -- basedir =/usr/local/mysql
/Usr/local/mysql/scripts/mysql_install_db -- datadir =/www/mysqldata3307/-- user = mysql -- basedir =/usr/local/mysql
/Usr/local/mysql/scripts/mysql_install_db -- datadir =/www/mysqldata3308/-- user = mysql -- basedir =/usr/local/mysql
5. to start mysql, specify the. cnf file and directory to start
/Usr/local/mysql/bin/mysqld_safe -- defaults-extra-file =/etc/my3306.cnf -- datadir =/www/mysqldata3306 -- user = mysql &
/Usr/local/mysql/bin/mysqld_safe -- defaults-extra-file =/etc/my3307.cnf -- datadir =/www/mysqldata3307 -- user = mysql &
/Usr/local/mysql/bin/mysqld_safe -- defaults-extra-file =/etc/my3308.cnf -- datadir =/www/mysqldata3308 -- user = mysql &
6. stop MYSQL and the corresponding sock file.
/Usr/local/mysql/bin/mysqladmin-uroot-S/tmp/mysql3308.sock shutdown
7. log on to mysql
Mysql-S/tmp/mysq3308.sock-P 3308
BitsCN.com