1. Single-boot multiple MySQL benefits
Make full use of the computing power of single machine
Can effectively allocate different logic to different MySQL improve database parallel processing capability
Single machine can also easily achieve master-slave backup
2. Example: Single computer to achieve two MySQL running, listening to the port is 3306,3307
Implementation mode
Modify MY.CNF: Put the original [mysqld]=>[mysqld1], to achieve the first default MySQL parameter of the 1 database. Then add a new MySQL database, the parameters are similar to the MYSQL1:
The following is a reference fragment:
[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 your own requirements.
Add the appropriate path according to the MYSQL2 configuration: Because DataDir is the folder path used to hold the database data. Therefore, you must build a corresponding folder (note that you want the database to have write permissions to the folder). You can copy the MYSQL1 folder to the new path first. Then modify the file permissions: for example
Cp/var/lib/mysql/var/lib/mysql2-r
CHOWN/VAR/LIB/MYSQL2 Mysql-r
Use Mysqld_multi to control the open shutdown of the database.
Mysqld_multi Start 1,2 1, 22 databases.
After running, you can use PS Aux|grep MySQL to see if the related process exists
Mysqld_multi Stop 1,2 closes 1, 2 databases.
Use client to view different databases
You can use mysql-p3307-uroot based on different ports to access, if the experiment is not feasible. You can use
Mysql-uroot-s/var/run/mysqld/mysql2.sock access.
This is the case with two examples, if you want to run multiple databases, you can use the same method.