The benefits of booting multiple MySQL on a stand-alone machine

Source: Internet
Author: User
Tags file permissions

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.

Related Article

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.