疯狂编程网

  • 首页
  • 后端
    • GOLANG
    • PHP
  • 前端
  • 客户端
  • 服务器
  • AIGC
  • 开发工具
  • 代码人生
  • 关于本站
    • 联系我们
    • 免责声明
  1. 首页
  2. 服务器
  3. MYSQL
  4. 正文

mysql安装及主从复制配置

2023年5月10日 302点热度 0人点赞 0条评论

一、安装mysql8.0

##下载mysql安装包 http://mirrors.sohu.com/mysql/MySQL-8.0/

  wget http://mirrors.sohu.com/mysql/MySQL-8.0/mysql-community-client-8.0.18-1.el7.x86_64.rpm

  wget  http://mirrors.sohu.com/mysql/MySQL-8.0/mysql-community-client-8.0.27-1.el7.x86_64.rpm

  wget  http://mirrors.sohu.com/mysql/MySQL-8.0/mysql-community-common-8.0.27-1.el7.x86_64.rpm

  wget  http://mirrors.sohu.com/mysql/MySQL-8.0/mysql-community-devel-8.0.27-1.el7.x86_64.rpm

  wget  http://mirrors.sohu.com/mysql/MySQL-8.0/mysql-community-embedded-compat-8.0.27-1.el7.x86_64.rpm

  wget  http://mirrors.sohu.com/mysql/MySQL-8.0/mysql-community-libs-8.0.27-1.el7.x86_64.rpm

  wget  http://mirrors.sohu.com/mysql/MySQL-8.0/mysql-community-libs-compat-8.0.27-1.el7.x86_64.rpm

 wget  http://mirrors.sohu.com/mysql/MySQL-8.0/mysql-community-server-8.0.27-1.el7.x86_64.rpm

 wget  http://mirrors.sohu.com/mysql/MySQL-8.0/mysql-community-client-plugins-8.0.27-1.el7.x86_64.rpm

##安装mysql

#yum localinstall ./mysql-community-*

##启动mysql

#systemctl start mysqld

##查看初始密码

##进入数据库修改密码

注意:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 提示密码不符合规则。

二、mysql主从复制配置

#首先安装mysql在主从服务节点安装mysql数据库,如上操作

#主库配置

1、##编辑配置文件

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

port=3306

server-id=100   #设置server_id

gtid-mode=on   #启用gtid,否则就是普通的复制架构

log-slave-updates  #slave更新是否计入日志

enforce-gtid-consistency    #强制gtid的一致性

log_bin=/data/mysql/mybinlog

max_connections=500

2、创建主从复制专用用户

#mysql -uroot -pWWW.123.com

>create user ‘slave’@’192.168.1.%’ identified by ‘WWW.123.com’;

>grant replication slave on *.* to ‘slave’@’192.168.1.%’;

3、查看主库的日志及偏移量

#从库配置

1、编辑配置文件my.cnf

2、进入mysql进行配置连接

#change master to master_host=’192.168.1.37’,master_user=’slave’,\

master_password=’WWW.123.com’,\

master_port=3306,master_auto_position=1;

3、查看slave状态,如下图表示主从复制配置完成

 

标签: mysql
最后更新:2023年5月10日

大明

靠写代码养家的开发者。

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2023 疯狂编程网. ALL RIGHTS RESERVED.

京ICP备2022013580号-1