Multiple instances of MySQL

Source: Internet
Author: User

First, the preparatory work
1. Close the MySQL process
# Pkill
# Service Mysqld Stop

2. Remove Mysqld from System services
# chkconfig--del mysqld

3. Delete Mysqld
# Rm-rf/etc/init.d/mysqld

4. Create a directory for each instance
# Mkdir/data/{3306/data,3307/data}-PV

5. Modify the instance Purpose permission
# Chown-r mysql.mysql/data/


Second, prepare the MySQL configuration file
1. Copy Template build configuration file
# CP/ROOT/MYSQL-5.5.19/SUPPORT-FILES/MY-LARGE.CNF/DATA/3306/MY.CNF
# CP/ROOT/MYSQL-5.5.19/SUPPORT-FILES/MY-LARGE.CNF/DATA/3307/MY.CNF

2. Edit the configuration file for two instances
[Client]
Port = 3307
Socket =/data/3307/mysql.sock

[Mysqld]
user = MySQL
Port = 3307
Socket =/data/3307/mysql.sock
Basedir =/usr/local/mysql
DataDir =/data/3307/data

Server-id = 7

[Mysqld_safe]
Log-error =/data/3307/err_3307.log
Pid-file =/data/3307/mysqld.pid


3. Initializing MySQL instance
#/root/mysql-5.5.19/scripts/mysql_install_db--user=mysql--datadir=/data/3307/data/--basedir=/usr/local/mysql/
#/root/mysql-5.5.19/scripts/mysql_install_db--user=mysql--datadir=/data/3306/data/--basedir=/usr/local/mysql/

4. Start each instance
#/usr/local/mysql/bin/mysqld_safe--DEFAULTS-FILE=/DATA/3306/MY.CNF &
#/usr/local/mysql/bin/mysqld_safe--DEFAULTS-FILE=/DATA/3307/MY.CNF &

5. Log in to MySQL
#/usr/local/mysql/bin/mysql-u Root-p-s/data/3306/mysql.sock
#/usr/local/mysql/bin/mysql-u Root-p-s/data/3307/mysql.sock

(If there is something wrong with the sock file, please modify it again.) Beginners Please give more advice, thank you. )

Multiple instances of MySQL

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.