One MySQL server starts multiple ports _ MySQL

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.