九.mysql数据库多实例安装mysqld_multi [start,stop,report]
经常应为系统硬件短缺,导致需要在同一台硬件服务器上面安装多个mysql实例。之前的文章四·安装mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz(基于Centos7源码安装)
1.在mysql用户目录下新建mysql3306,mysql3307,mysql3308三个文件夹,并分别在这三个文件夹下建立data,log,tmp文件夹,总体目录结构如下
/home/mysql
├── mysql3306
├──data
├──log
├──tmp
├── mysql3307
├──data
├──log
├──tmp
├── mysql3308
├──data
├──log
├──tmp
2.配置my.cnf文件
[client] port=3306 socket=/tmp/mysql.sock [mysqld_multi] mysqld=/usr/local/mysql/bin/mysqld_safe mysqladmin=/usr/local/mysql/bin/mysqladmin log=/home/mysql/mysqld_multi.log [mysqld] user=mysql basedir=/usr/local/mysql sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysqld3306] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/mysql3306/data port=3306 server_id=3306 socket=/tmp/mysql3306.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3306/log/slow.log log-error = /home/mysql/mysql3306/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3306/log/mysql3306_bin [mysqld3307] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/mysql3307/data port=3307 server_id=3307 socket=/tmp/mysql3307.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3307/log/slow.log log-error = /home/mysql/mysql3307/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3307/log/mysql3307_bin [mysqld3308] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/mysql3308/data port=3308 server_id=3308 socket=/tmp/mysql3308.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3308/log/slow.log log-error = /home/mysql/mysql3308/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3308/log/mysql3308_bin
3.运行mysqld_multi
# 启动
/usr/local/mysql/bin/mysqld_multi start
# 停止
/usr/local/mysql/bin/mysqld_multi stop
# 查询状态
/usr/local/mysql/bin/mysqld_multi report
微信公众号:
Randy的技术笔记
如果您认为阅读这篇博客让您有些收获,不妨点击一下右下角的【推荐】
如果您希望与我交流互动,欢迎关注微信公众号
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。