Running two MySQL instances on the same server
It's not that complicated, two MySQL instances use different directory stores, use different port accesses, and load different configuration files.
If there are two MySQL A and b
MYSQL A is a system-standard RPM program installed. stored in the/var/lib/mysql configuration file for/etc/my.cnf, it's nothing special to change anything.
Now you need to run the second MySQL B, and you won't be able to rpm. Compile the installation using the source package. Specify the installation location as/USR/LOCAL/MYSQLB
The main compilation parameters are as follows:
./configue–prefix=/usr/local/mysqlb
Installation steps skipped ...
After installation, copy the configuration file/etc/my.cnf to/etc/myb.cnf.
and modify one of the
port=3307
Basedir=/usr/local/mysqlb
Datadir=/usr/local/mysqlb/var
After saving, manually specify the configuration file to start MySQL B:
/usr/local/mysqlb/bin/mysqld_safe–defaults-file=/etc/myb.cnf
Netstat to check it out, there are already 3306 33,072 MySQL running.
Specify the configuration file
Copy a my_setting.cnf, modified to 3340
/data/apps/mysql/bin/mysqld_safe--defaults-file=/data/apps/mysql/var/my_setting.cnf--user=mysql &
Note that the parameters of the specified configuration file should appear in the first position, the position of the interchange two parameters will be wrong, after startup, it is indeed 3340
6 Modifying Startup Parameters
/data/apps/mysql/bin/mysqld_safe--defaults-file=/data/apps/mysql/var/my_setting.cnf--user=mysql--port=3341 &
3341 Port after startup
#/usr/local/mysql/bin/mysqladmin-u Root-p shutdown