十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
这篇文章主要介绍多实例安装mysql 5.7的示例分析,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站建设、成都网站制作、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的福山网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!datadir:
mkdir -p /home/data/3306
mkdir -p /home/data/3307
mkdir -p /home/data/3308
chown -R mysql /home/data/
cd /opt/mysql
初始化mysql
./bin/mysqld --initialize --datadir=/home/data/3306 --user=mysql
./bin/mysqld --initialize --datadir=/home/data/3307 --user=mysql
./bin/mysqld --initialize --datadir=/home/data/3308 --user=mysql
启动mysql
bin/mysqld_safe --defaults-file=/opt/mysql/3306.cnf --user=mysql &
bin/mysqld_safe --defaults-file=/opt/mysql/3307.cnf --user=mysql &
bin/mysqld_safe --defaults-file=/opt/mysql/3308.cnf --user=mysql &
修改密码
注意:执行bin/mysqld --initialize的时候,日志会输出初始化的密码
关键字 A temporary password is generated for root@localhost:
mysql> set password = password('rootroot');
mysql> flush privileges;
配置环境变量
vim /etc/profile 添加
export PATH=$PATH:/opt/mysql/bin
刷新环境变量
source /etc/profile
配置别名
vim /root/.bashrc
```
alias mysql3306='mysql -uroot -prootroot -P3306 --socket=/home/data/3306/mysql.sock'
alias start_mysql_3306='/opt/mysql/bin/mysqld_safe --defaults-file=/opt/mysql/3306.cnf --user=mysql &'
alias stop_mysql_3306='mysqladmin shutdown -uroot -p"rootroot" --socket=/home/data/3306/mysql.sock'
alias mysql3307='mysql -uroot -prootroot -P3307 --socket=/home/data/3307/mysql.sock'
alias start_mysql_3307='/opt/mysql/bin/mysqld_safe --defaults-file=/opt/mysql/3307.cnf --user=mysql &'
alias stop_mysql_3307='mysqladmin shutdown -uroot -p"rootroot" --socket=/home/data/3307/mysql.sock'
alias mysql3308='mysql -uroot -prootroot -P3308 --socket=/home/data/3308/mysql.sock'
alias start_mysql_3308='/opt/mysql/bin/mysqld_safe --defaults-file=/opt/mysql/3308.cnf --user=mysql &'
alias stop_mysql_3308='mysqladmin shutdown -uroot -p"rootroot" --socket=/home/data/3308/mysql.sock'
```
建立主从
change master to
MASTER_HOST="192.168.64.52",
MASTER_USER="root",
MASTER_PASSWORD="rootroot",
MASTER_PORT=3306,
MASTER_CONNECT_RETRY=10,
MASTER_AUTO_POSITION = 1;
编辑 /opt/mysql/3306.cnf
```
[mysql]
prompt = "\u@master \R:\m:\s [\d]> "
[client]
port = 3306
socket = /data/mysql/data/mysql.sock
[mysqld]
datadir=/home/data/3306
socket=/home/data/3306/mysql.sock
skip-name-resolve
symbolic-links=0
log_bin = binlog
binlog_format= ROW
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
innodb_buffer_pool_size =512MB
innodb_buffer_pool_instances = 1
[mysqld_safe]
log-error=/home/data/3306/mysqld-err.log
```
编辑 /opt/mysql/3307.cnf
```
[mysql]
prompt = "\u@3307\R:\m:\s [\d]> "
[client]
port =3307
socket = /data/mysql/data/mysql.sock
[mysqld]
datadir=/home/data/3307
socket=/home/data/3307/mysql.sock
skip-name-resolve
symbolic-links=0
log_bin = binlog
binlog_format= ROW
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
innodb_buffer_pool_size =512MB
innodb_buffer_pool_instances = 1
```
编辑 /opt/mysql/3308.cnf
```
[mysql]
prompt = "\u@3308\R:\m:\s [\d]> "
[client]
port =3308
socket = /data/mysql/data/mysql.sock
[mysqld]
datadir=/home/data/3308
socket=/home/data/3308/mysql.sock
skip-name-resolve
symbolic-links=0
log_bin = binlog
binlog_format= ROW
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
innodb_buffer_pool_size =512MB
innodb_buffer_pool_instances = 1
```
以上是“多实例安装mysql 5.7的示例分析”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联-成都网站建设公司行业资讯频道!