分享更有价值
被信任是一种快乐

mysqld_multi如何安装多个mysql实例

文章页正文上

这篇文章主要介绍mysqld_multi如何安装多个mysql实例,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
一个机器上安装多个mysql实例,除了将每个实例在不同的目录下编译安装,为每个实例指定不同的端口,socket,配置文件,安装目录等。还可以使用mysqld_multi方式。mysqld_multi是mysql设计的专门用来管理不同端口,不同socket的mysql实例的工具。它可以同时启动,停止多个mysql实例,也可以查看这些实例的状态。mysqld_multi会去配置文件my.cnf(或者是—defaults-file参数指定的配置文件)中检查每一个以[mysqldN]为开头的一组配置(N这里是数字)。这个N是mysqld_multi用来区分每一个mysql实例用的。用法如下:mysqld_multi start|stop|reload|report
N1, N2, N3,… //reload等价于stop和start。mysqld_multi需要的信息记录在配置文件my.cnf中的[mysqld_multi]组下。
注意,为了能用mysqld_multi统计管理所有的mysql实例,该管理账号必须存在于所有的mysql实例上,而且密码也一致。
以下是我做的测试以及安装步骤:1、 编写配置文件my.cnf,如下:[root@CentOSMysql1 etc]# cat
my.cnf[mysqld_multi]mysqld=mysqld_safe#表示用mysqld_safe来启动mysqlmysqladmin=/usr/local/mysql/bin/mysqladmin#指定mysqladmin工具的路径log=/usr/local/mysql/mysqld_multi.log#指定mysqld_multi的日志文件user=rootpass=123456#指定使用mysqld_multi工具的用户和密码[mysqld3307]#指定实例编号为3307的一些配置参数datadir=/opt/data3307port=3307socket=/tmp/mysql.sock3307[mysqld3308]#指定实例编号为3308的一些配置参数datadir=/opt/data3308port=3308socket=/tmp/mysql.sock3308[mysqld56]#指定实例编号为56的一些配置参数basedir=/usr/local/mysql56/datadir=/opt/data56socket=/tmp/mysql.sock56port=33102、 准备安装之前工作(1)查看是否有mysql用户和mysql组[root@CentOSMysql1 etc]# cat
group |grep mysql[root@CentOSMysql1 etc]#
groupadd mysql[root@CentOSMysql1 mysql]# cat
/etc/passwd|grep mysql[root@CentOSMysql1 etc]#
useradd -g mysql mysql(2)下载mysql的安装文件。这里我下载的都是linux generic类型的[root@CentOStest1 opt]# wgethttp://downloads.mysql.com/archives/get/file/mysql-5.6.19-linux-glibc2.5-x86_64.tar.gz[root@CentOStest1
opt]# wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz(3)解压这些安装包[root@CentOSMysql1 opt]# tar
-zxf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz[root@CentOSMysql1 opt]# tar
-zxf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz3、 安装编号为3307的mysql实例,这里我计算用mysql5.7的版本。[root@CentOSMysql1 opt]#mv mysql-5.7.16-linux-glibc2.5-x86_64 /usr/local[root@CentOSMysql1 opt]#cd /usr/local/[root@CentOSMysql1 local]#ln –s mysql-5.7.16-linux-glibc2.5-x86_64
mysql[root@CentOSMysql1 local]# cd
mysql[root@CentOSMysql1 mysql]# chown -R mysql:mysql .[root@CentOSMysql1 mysql]# bin/mysqld
–initialize –user=mysql –datadir=/opt/data3307//这条命令执行成功之后,会在结尾打印出临时密码,如下:2017-12-21T02:08:32.598340Z 0
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use
–explicit_defaults_for_timestamp server option (see docu免费主机域名mentation for more
details).2017-12-21T02:08:33.002195Z 0
[Warning] InnoDB: New log files created, LSN=457902017-12-21T02:08:33.090315Z 0
[Warning] InnoDB: Creating foreign key constraint system tables.2017-12-21T02:08:33.179548Z 0
[Warning] No existing UUID has been found, so we assume that this is the first
time that this server has been started. Generating a new UUID:
d898cae9-e5f3-11e7-9e66-000c299323ae.2017-12-21T02:08:33.181477Z 0
[Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’
cannot be opened.2017-12-21T02:08:33.184759Z 1
[Note] A temporary password is generated for root@localhost: L;0/g:XaweYi[root@CentOSMysql1
mysql]# bin/mysql_ssl_rsa_setup
–datadir=/opt/data3307
到这里,编号为3307的实例初步安装完毕,还剩下一个步骤就是修改临时密码。改密码之前需要把其所在mysql服务启动起来,这里我们用mysqld_multi启动,先查看下状态,如下:[root@CentOSMysql1
bin]# mysqld_multireport-bash: mysqld_multi: command
not found
解决方法为将mysqld_multi工具所在的路径添加到环境变量中去:[root@CentOSMysql1 bin]# vi
/etc/profile//在文件尾部添加以下语句PATH=/usr/local/mysql/bin:$PATH”/etc/profile” 79L,
1828C written[root@CentOSMysql1 bin]#
source /etc/profile
环境变量生效之后重试[root@CentOSMysql1 mysql]#
mysqld_multi reportReporting MySQL serversMySQL server from group:
mysqld3307 is not runningMySQL server from group:
mysqld3308 is not runningMySQL server from group:
mysqld56 is not running[root@CentOSMysql1 mysql]#
mysqld_multi start 3307[root@CentOSMysql1 mysql]#
mysqld_multi reportReporting MySQL serversMySQL server from group:
mysqld3307 is runningMySQL server from group: mysqld3308
is not runningMySQL server from group:
mysqld56 is not running
可以看到编号3307的mysql实例已经启动,然后修改root密码。因为my.cnf里面配置了root用户的密码是123456,所以现在我们将root的密码改为“123456”:[root@CentOSMysql1
mysql]# mysql -uroot -p -S /tmp/mysql.sock3307Enter password://这里输出刚才安装时出现的临时密码。mysql> set password=password(“123456”);
到这里,编号为3307的实例安装完毕。4、 安装编号为3308的mysql实例,这里仍用mysql5.7的版本,但是端口号以及datadir要根据my.cnf中的来。[root@CentOSMysql1 mysql]#
bin/mysqld –initialize –user=mysql –datadir=/opt/data33082017-12-21T02:36:31.294011Z 0
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use
–explicit_defaults_for_timestamp server option (see documentation for more
details).2017-12-21T02:36:31.779696Z 0
[Warning] InnoDB: New log files created, LSN=457902017-12-21T02:36:31.881428Z 0
[Warning] InnoDB: Creating foreign key constraint system tables.2017-12-21T02:36:31.948774Z 0
[Warning] No existing UUID has been found, so we assume that this is the first
time that this server has been started. Generating a new UUID: c138a63c-e5f7-11e7-8f7a-000c299323ae.2017-12-21T02:36:31.950062Z 0
[Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’
cannot be opened.2017-12-21T02:36:31.953758Z 1
[Note] A temporary password is generated for root@localhost: whKyXCtxz9;g//临时密码同样在尾处生成。[root@CentOSMysql1 mysql]#
bin/mysql_ssl_rsa_setup
–datadir=/opt/data3308
拉起编号3308的mysql实例服务[root@CentOSMysql1 mysql]#
mysqld_multi start 3308
修改编号3308的mysql实例中root用户的密码为“123456”。[root@CentOSMysql1 mysql]#
mysql -uroot -p -S /tmp/mysql.sock3308Enter password://这里输出刚才安装时出现的临时密码。mysql> set
password=password(“123456”);
到这里,编号为3308的实例安装完毕。5、 安装编号为56的mysql实例,这里使用mysql5.6的版本,由安装目录,端口号以及datadir根据my.cnf中的来。[root@CentOSMysql1 opt]#mv mysql-5.6.34-linux-glibc2.5-x86_64
/usr/local[root@CentOSMysql1 opt]#cd
/usr/local/[root@CentOSMysql1 local]#ln
–s mysql-5.6.34-linux-glibc2.5-x86_64 mysql56[root@CentOSMysql1 local]# cd
mysql56[root@CentOSMysql1 mysql56]#
chown -R mysql:mys免费主机域名ql .[root@CentOSMysql1 mysql56]#
scripts/mysql_install_db –user=mysql
–datadir=/opt/data56
这一步和mysql5.7有些不一样,不会生成临时密码。Mysql5.6的临时密码默认是空。[root@CentOSMysql1 local]#
mysqld_multi start 56
拉起编号56的mysql实例服务[root@CentOSMysql1 local]#
mysql -uroot -p -S /tmp/mysql.sock56
修改编号56的mysql实例中root用户的密码为“123456”。mysql> set
password=”123456″;ERROR 1372 (HY000): Password
hash should be a 41-digit hexadecimal numbermysql> set
password=password(“123456”);
到这里,编号为56的实例安装完毕。6、 最后,试试用mysqld_multi统一起停所有的mysql实例[root@CentOSMysql1 ~]#
mysqld_multi reportReporting MySQL serversMySQL server from group:
mysqld3307 is runningMySQL server from group:
mysqld3308 is runningMySQL server from group:
mysqld56 is running[root@CentOSMysql1 ~]#
mysqld_multi reportReporting MySQL serversMySQL server from group:
mysqld3307 is runningMySQL server from group:
mysqld3308 is runningMySQL server from group:
mysqld56 is running[root@CentOSMysql1 ~]#
mysqld_multi stop[root@CentOSMysql1 ~]#
mysqld_multi reportReporting MySQL serversMySQL server from group:
mysqld3307 is not runningMySQL server from group:
mysqld3308 is not runningMySQL server from group:
mysqld56 is not running[root@CentOSMysql1 ~]#
mysqld_multi start[root@CentOSMysql1 ~]#
mysqld_multi reportReporting MySQL serversMySQL server from group:
mysqld3307 is runningMySQL server from group:
mysqld3308 is runningMySQL server from group:
mysqld56 is running以上是“mysqld_multi如何安装多个mysql实例”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注云技术行业资讯频道!

相关推荐: sql语句with as的用法详解

这篇文章主要介绍“sql语句with as的用法详解”,在日常操作中,相信很多人在sql语句with as的用法详解问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”sql语句with as的用法详解”的疑惑有所帮助!接下来,请跟着…

文章页内容下
赞(0) 打赏
版权声明:本站采用知识共享、学习交流,不允许用于商业用途;文章由发布者自行承担一切责任,与本站无关。
文章页正文下
文章页评论上

云服务器、web空间可免费试用

宝塔面板主机、支持php,mysql等,SSL部署;安全高速企业专供99.999%稳定,另有高防主机、不限制内容等类型,具体可咨询QQ:360163164,Tel同微信:18905205712

主机选购导航云服务器试用

登录

找回密码

注册