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.