当前位置:Gxlcms > 数据库问题 > MySQL5.6多实例部署

MySQL5.6多实例部署

时间:2021-07-01 10:21:17 帮助过:2人阅读

 

进入到mysql的scripts文件夹下对数据库进行初始化,这里我们对3306端口数据库进行初始化

1 [root@HE1 scripts]#./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_3306 --defaults-file=/etc/my.cnf --user=mysql

 

这里我们对3308端口数据库进行初始化

1 2 [root@HE1 scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_3308 --defaults-file=/etc/my.cnf --user=mysql

 

 

初始化完成后,我们便可以启停数据库了,和单实例不同,多实例采用mysqld_multi来启停数据库

[root@HE1 bin]# ./mysqld_multi --defaults-file=/etc/my.cnf --user=root --password=MANAGER start 3306,3308

 

可以利用mysqld_multi的report命令来检测多实例的运行状况

1 2 3 4 5 [root@HE1 bin]# ./mysqld_multi report Reporting MySQL servers MySQL server from group: mysqld3306 is running MySQL server from group: mysqld3308 is running

 

 

登录方式和单实例大体相同,不过由于多实例的存在,我们需要指定不同的端口号

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 [root@HE1 bin]# mysql -uroot -p -P3306 -h 192.168.1.48 Enter password: Welcome to the MySQL monitor.  Commands end with or \g. Your MySQL connection id is 6 Server version: 5.6.16-log MySQL Community Server (GPL)    Copyright (c) 2000, 2014, 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> show databases; +--------------------+ Database           | +--------------------+ | information_schema | | 3306db             | | mysql              | | performance_schema | | test               | +--------------------+ rows in set (0.00 sec)

 

 

当然,利用socket文件登录也是可以的

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 [root@HE1 bin]#mysql -uroot -p -S /data/mysql_3306/mysql_3306.sock Enter password: Welcome to the MySQL monitor.  Commands end with or \g. Your MySQL connection id is 7 Server version: 5.6.16-log MySQL Community Server (GPL)    Copyright (c) 2000, 2014, 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> show databases; +--------------------+ Database           | +--------------------+ | information_schema | | 3306db             | | mysql              | | performance_schema | | test               | +--------------------+ rows in set (0.00 sec)

 

这里是登录3308端口数据库

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 [root@HE1 bin]#mysql -uroot -p -P3308 -h 192.168.1.48 Enter password: Welcome to the MySQL monitor.  Commands end with or \g. Your MySQL connection id is 8 Server version: 5.6.16-log MySQL Community Server (GPL)    Copyright (c) 2000, 2014, 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.       Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.    mysql> show databases; +--------------------+ Database           | +--------------------+ | information_schema | | 3308db             | | mysql              | | performance_schema | | test               | +--------------------+ rows in set (0.00sec)    mysql> quit Bye

 

 

 利用3308端口的socket文件登录数据库

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [root@HE1 bin]#mysql -uroot -p -S /data/mysql_3308/mysql_3308.sock Enter password: Welcome to the MySQL monitor.  Commands end with or \g. Your MySQL connection id is 9 Server version: 5.6.16-log MySQL Community Server (GPL)    Copyright (c) 2000, 2014, 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> show databases; +--------------------+ Database           | +--------------------+ | information_schema | | 3308db             | | mysql              | | performance_schema | | test               | +--------------------+ rows in set (0.00sec)

 

 

至此,MySQL5.6多实例部署完成。

本文出自 “岁伏” 博客,请务必保留此出处http://suifu.blog.51cto.com/9167728/1850560

MySQL5.6多实例部署

标签:

人气教程排行