Start multiple mysql_MySQL instances in mysqld_multi single-host environment

Source: Internet
Author: User
Mysqld_multi start multiple mysql instances in a single environment 1. benefits of starting multiple mysql instances on a single machine

◆ Make full use of the computing power of a single machine

◆ It can effectively allocate different logics to different mysql databases to improve the parallel processing capability of databases.

◆ A single machine can also easily implement master-slave backup

2. instance: two mysql instances are run on a single machine. the listening ports are 3306 and 3307, respectively.

Implementation method

◆ Modify my. cnf: set the original [mysqld] => [mysqld1] to implement the first default mysql parameter 1 database. then add a new mysql database with the following parameters:

The following is a reference clip:

[Mysqld2]
User = mysql
Pid-file =/var/run/mysqld/mysqld2.pid
Socket =/var/run/mysqld/mysqld2.sock
Port = 3307
Datadir =/var/lib/mysql2
Bind-address = 127.0.0.1
Log =/var/lib/mysql2/log. log

The above is the configuration of the second database. Of course, you can modify it as required.

◆ Add the corresponding path according to mysql2 configuration: because datadir is the folder path used to store database data. Therefore, you must create a corresponding folder (ensure that the database has the write permission on the folder ). You can copy the mysql1 folder to the new path first. Then modify the file permission, for example

Cp/var/lib/mysql/var/lib/mysql2-R
Chown/var/lib/mysql2 mysql-R

◆ Use mysqld_multi to enable and disable the control database.

Mysqld_multi start 1 and 2 start two databases.

After running, you can use ps aux | grep mysql to check whether the related process exists.

Mysqld_multi stop 1 and 2 shut down 1 and 2 databases.

◆ Use the client to view different databases

You can use mysql-P3307-uroot to access the database based on different ports. You can use

Mysql-uroot-S/var/run/mysqld/mysql2.sock access.

Now the two instances have been introduced. if you want to run multiple databases, you can use the above method.

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.