# mysqladmin ping
mysqld is alive #服务器正在运行
# mysqladmin shutdown #关闭之
# ps -ef |grep mysql
root 7995 7975 0 20:44 pts/1 00:00:00 grep mysql #确认已经关闭
#mkdir -p /opt/mysql-5.6.10/data2
mkdir -p /opt/mysql-5.6.10/data3
# cd /opt/mysql-5.6.10
# chown mysql.mysql ./data2 –R
# chown mysql.mysql ./data3 –R
[root@centos mysql-5.6.10]# ./scripts/mysql_install_db --basedir=/opt/mysql-5.6.10 --datadir=/opt/mysql-5.6.10/data2 --user=mysql
[root@centos mysql-5.6.10]# ./scripts/mysql_install_db --basedir=/opt/mysql-5.6.10 --datadir=/opt/mysql-5.6.10/data3 --user=mysql
[root@centos mysql-5.6.10]# cd data2
[root@centos data2]# ll
total 110604
-rw-rw----. 1 mysql mysql 12582912 Mar 5 22:02 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Mar 5 22:02 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Mar 5 20:57 ib_logfile1
drwx------. 2 mysql mysql 4096 Mar 5 20:57 mysql
drwx------. 2 mysql mysql 4096 Mar 5 22:02 performance_schema
drwx------. 2 mysql mysql 4096 Mar 5 20:57 test
# cp my.cnf my.cnf.bak
[mysqld_multi]
mysqld = /opt/mysql-5.6.10/bin/mysqld_safe
mysqladmin = /opt/mysql-5.6.10/bin/mysqladmin
user = groad
password = 123456
[mysqld1]
socket = /tmp/mysql1.sock
port = 3306
pid-file = /tmp/mysql1.pid
basedir = /opt/mysql-5.6.10
datadir = /opt/mysql-5.6.10/data
log_error = /opt/mysql-5.6.10/mysql1_error.log
user = mysql
[mysqld2]
socket = /tmp/mysql2.sock
port = 3307
pid-file = /tmp/mysql2.pid
basedir = /opt/mysql-5.6.10
datadir = /opt/mysql-5.6.10/data2
log_error = /opt/mysql-5.6.10/mysql2_error.log
user = mysql
[mysqld3]
socket = /tmp/mysql3.sock
port = 3308
pid-file = /tmp/mysql3.pid
basedir = /opt/mysql-5.6.10
datadir = /opt/mysql-5.6.10/data3
log_error = /opt/mysql-5.6.10/mysql3_error.log
user = mysql
mysqld_multi [options] {start|stop|reload|report} [GNR[,GNR] ...]
[root@centos mysql-5.6.10]# ./bin/mysqld_multi --defaults-file=./my.cnf start 1
[root@centos mysql-5.6.10]# ps -ef | grep "mysql"
root 8677 1 0 23:13 pts/1 00:00:00 /bin/sh /opt/mysql-5.6.10/bin/mysqld_safe --socket=/tmp/mysql1.sock --port=3306 --pid-file=/tmp/mysql2.pid --basedir=/opt/mysql-5.6.10 --datadir=/opt/mysql-5.6.10/data --log_error=/opt/mysql-5.6.10/mysql1_error.log --user=mysql
mysql 8834 8677 17 23:13 pts/1 00:00:00 /opt/mysql-5.6.10/bin/mysqld --basedir=/opt/mysql-5.6.10 --datadir=/opt/mysql-5.6.10/data --plugin-dir=/opt/mysql-5.6.10/lib/plugin --user=mysql --log-error=/opt/mysql-5.6.10/mysql1_error.log --pid-file=/tmp/mysql2.pid --socket=/tmp/mysql1.sock --port=3306
root 8858 7975 0 23:14 pts/1 00:00:00 grep mysql
# ./bin/mysqld_multi --defaults-file=./my.cnf start 2
# ./bin/mysqld_multi --defaults-file=./my.cnf start 3
[root@centos mysql-5.6.10]# mysql -S /tmp/mysql1.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.10 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
[root@centos mysql-5.6.10]# mysql -S /tmp/mysql2.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.10 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
[root@centos mysql-5.6.10]# ./bin/mysqld_multi --defaults-file=./my.cnf stop 1
[root@centos mysql-5.6.10]# ps -ef |grep "3306"
root 2116 1 0 Mar05 pts/0 00:00:00 /bin/sh /opt/mysql-5.6.10/bin/mysqld_safe --socket=/tmp/mysql1.sock --port=3306 --pid-file=/tmp/mysql1.pid --basedir=/opt/mysql-5.6.10 --datadir=/opt/mysql-5.6.10/data --log_error=/opt/mysql-5.6.10/mysql1_error.log --user=mysql
mysql 2271 2116 0 Mar05 pts/0 00:00:00 /opt/mysql-5.6.10/bin/mysqld --basedir=/opt/mysql-5.6.10 --datadir=/opt/mysql-5.6.10/data --plugin-dir=/opt/mysql-5.6.10/lib/plugin --user=mysql --log-error=/opt/mysql-5.6.10/mysql1_error.log --pid-file=/tmp/mysql1.pid --socket=/tmp/mysql1.sock --port=3306
root 2771 2092 0 00:11 pts/0 00:00:00 grep 3306
[root@centos mysql-5.6.10]# mysql -S /tmp/mysql1.sock # 先登录 mysql1 这个服务器实例
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.10 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>grant shutdown on *.* to 'groad'@'localhost' identified by '123456'; #注意一定要给出 my.cnf 文件里给出的密码
Query OK, 0 rows affected (0.00 sec)
[root@centos mysql-5.6.10]# ./bin/mysqld_multi --defaults-file=./my.cnf stop 1
[root@centos mysql-5.6.10]# ps -ef |grep "3306"
root 2858 2092 0 00:39 pts/0 00:00:00 grep 3306
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |