MySQL Multi-instance installation

Source: Internet
Author: User

installation MySQL Dependency Packages

Yum install-y ncurses-devel Libaio-devel


Configure a different my.cnf

ports and file paths, and Server-id

[Client]

port=3306

Socket=/data/3306/mysql.sock

[Mysqld]

port=3306

Socket=/data/3306/mysql.sock

Basedir=/usr/local/mysql

Datadir=/data/3306/data

Log-error=/data/3306/error.log

log-slow-queries=/data/3306/slow.log

Pid-file=/data/3306/mysql.pid

Log-bin=/data/3306/mysql-bin

Relay-log=/data/3306/relay-bin

Skip-external-locking

Key_buffer_size= 16K

max_allowed_packet= 1M

Table_open_cache= 4

Sort_buffer_size= 64K

Read_buffer_size= 256K

Read_rnd_buffer_size= 256K

Net_buffer_length= 2K

thread_stack= 128K

Server-id=1

[Mysqldump]

Quick

max_allowed_packet= 16M

[MySQL]

No-auto-rehash

[Myisamchk]

Key_buffer_size= 8M

Sort_buffer_size= 8M

[Mysqlhotcopy]

Interactive-timeout


Initialization

/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/data/3306/data--user=mysql

/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/data/3307/data--user=mysql


Startup scripts

MYSQLD_SAFE--DEFAULTS-FILE=/DATA/3306/MY.CNF 2>&1 >/dev/null &

MYSQLD_SAFE--DEFAULTS-FILE=/DATA/3307/MY.CNF 2>&1 >/dev/null &

Stop script

Mysqladmin-u root-p passwd-s/data/3306/mysql.sock shutdown

Login MySQL

Mysql-s/data/3306/mysql.sock

Systemmysql-s/data/3307/mysql.sock


Set Password

Mysqladmin-u root-s/data/3306/mysql.sock password ' password '





mysqld Start the program


#!/bin/sh


port=3306

Mysql_user= "Root"

Mysql_pwd= "123qwe"

Cmdpath= "/usr/local/mysql/bin"

mysql_sock= "/data/${port}/mysql.sock"


Start_mysql () {

if[!-e ${mysql_sock}]

Then

printf "Starting mysql...\n"

/bin/sh${cmdpath}/mysqld_safe--defaults-file=/data/${port}/my.cnf 2>&1>/dev/null &

Fi

}


Stop_mysql () {

printf "stoping mysql...\n"

#/bin/sh${cmdpath}/

Mysqladmin-u${mysql_user}-p${mysql_pwd}-s/data/${port}/mysql.sock shutdown

}


Restart_mysql () {

printf "Restarting mysql...\n"

Stop_mysql

Start_mysql

}


Kill_mysql () {

Kill-9 $ (Ps-ef | grep ' Bin/mysqld_safe ' | grep ${port} | awk ' {printf$2} ')

Kill-9 $ (Ps-ef | grep ' Libexec/mysqld ' | grep ${port} | awk ' {printf$2} ')

}


Case$1 in

Start

Start_mysql;;

Stop

Stop_mysql;;

Kill

Kill_mysql;;

Restart

Restart_mysql;;

*)

echo "Usage:/data/dbdata_${port}/mysqld {start|stop|restart|kill}";;

Esac



Authorizing remote connections

Grantall Privileges On * * to ' root ' @ '% ' identified by ' 123qwe ' with grantoption;

MySQL Multi-instance installation

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.