一、安装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状态,如下图表示主从复制配置完成
文章评论