大家好,我是考100分的小小码 ,祝大家学习进步,加薪顺利呀。今天说一说mysql安装及主从复制配置[通俗易懂],希望您对编程的造诣更进一步.
一、安装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状态,如下图表示主从复制配置完成
原文地址:https://www.cnblogs.com/rickenl/archive/2022/05/20/16293791.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/5225.html