Install and start multiple MySQL instances in Linux

Source: Internet
Author: User

Found onlineNIf you have more information, none of them will succeed successfully. If you are depressed, the level may be limited ...! I have been continuously researching, testing, and fully implementedLinuxStart twoMysql, and have a better understanding of mysql!

 

The procedure is as follows:

I. Compile and install twoMysqlThe steps are as follows:

DownloadMysql, HereMysql-6.0.11-alpha.tar.gzExample

 

Install the first database(Primary Database)

(RedSome are default database file paths and can be changed to others, such:Data,VarAnd so on)

Tar zxvf mysql-6.0.11-alpha.tar.gz

Cd mysql-6.0.11-alpha

. /Configure -- prefix =/usr/local/mysql -- sysconfdir =/usr/local/mysql/etc -- with-tcp-port = 3306 -- localstatedir =/usr/local/mysql/Localstate-- With-unix-socket-path =/tmp/mysql3306.sock -- with-charset = utf8 -- with-collation = utf8_general_ci -- with-extra-charsets = gbk, gb2312, binary -- enable-thread-safe-client -- with-plugins = innobase -- with-mysqld-user = mysql -- with-charset = utf8-- With-client-ldflags =-all-static -- with-mysqld-ldflags =-all-static

Make & make install

 

Install the second database(Slave Database)

Tar zxvf mysql-6.0.11-alpha.tar.gz

Cd mysql-6.0.11-alpha

. /Configure -- prefix =/usr/local/mysql3307 -- sysconfdir =/usr/local/mysql3307/etc -- with-tcp-port = 3307 -- localstatedir =/usr/local/mysql3307/Localstate-- With-unix-socket-path =/tmp/mysql3307.sock -- with-charset = utf8 -- with-collation = utf8_general_ci -- with-extra-charsets = gbk, gb2312, binary -- enable-thread-safe-client -- with-plugins = innobase -- with-mysqld-user = mysql -- with-charset = utf8-- With-client-ldflags =-all-static -- with-mysqld-ldflags =-all-static

Make & make install

 

To modify all character sets:-- With-extra-charsets =AllYou can.

 

2. initialize the database scripts respectively (under the compiled directory)

Scripts/mysql_install_db -- basedir =/usr/local/mysql/-- user = mysql

Scripts/mysql_install_db -- basedir =/usr/local/mysql3307/-- user = mysql

Note: available-- Datadir = PATHThe parameter specifies the database file path. The default value is compile time.-- Localstatedir

 

3. Modify the slave Database Configuration File

Copy the configuration file:

Cp/usr/local/software/mysql-6.0.11-alpha/support-files/my-medium.cnf/usr/local/mysql/etc/my. cnf

Cp/usr/local/software/mysql-6.0.11-alpha/support-files/my-medium.cnf/usr/local/mysql3307/etc/my. cnf

 

4. ModifyMy. cnfFile

The main content is as follows:

AddInnoDBSupported:

[Client]

# Password= Your_password

Port=3307--Database port number

Socket= /Tmp/mysqls. sock-- SockFile Path

Default-character-set = utf8--ClientUTF8Connection

[Mysqld]

Port= 3307--Database port number

Socket=/Tmp/mysqls. sock-- SockFile Path

Default-storage-engine = INNODB

Default-character-set = UTF8--Default Character Set

Init_connect = 'set NAMES utf8'--ToUTF8Connection

Skip-name-resolve--CancelDNSReverse resolution

Lower_case_table_names = 1--Case Insensitive table names

 

Start the database (go to their respective directories)

MASTER:./Mysqld_safe &

From:./Mysqld_safe &

Enable Automatic Configuration:

Cp/usr/local/software/mysql-6.0.11-alpha/support-files/mysql. server/etc/init. d/mysql

Cp/usr/local/software/mysql-6.0.11-alpha/support-files/mysql. server/etc/init. d/mysql3307

Modify basedir and datadir in/etc/init. d/mysql3007

Basedir =/usr/local/mysql3307
Datadir =/usr/local/mysql3307/var

 

Stop Database

MASTER:./Mysqladmin shutdown

From:./Mysqladmin shutdown

You can modify the configurations to meet your business needs.

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.