MySQL主从安装
mysql 5.7
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server (yum install mysql-community-server --nogpgcheck)
systemctl start mysqld.service
grep "password" /var/log/mysqld.log
mysql -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password';
exit
systemctl restart mysqld.service
(首先需要设置密码的验证强度等级,设置 validate_password_policy 的全局参数为 LOW 即可,
输入设值语句 “ set global validate_password_policy=LOW; ” 进行设值,)
CREATE USER 'slave'@'%' IDENTIFIED BY 'Oig#123456';
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'slave'@'%';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Password';
show variables like 'log_bin';
show master status;
stop slave;
mysql> CHANGE MASTER TO MASTER_HOST='10.16.129.12', MASTER_PORT=3306, MASTER_USER='slave', MASTER_PASSWORD='Ab!@3456', MASTER_LOG_FILE='mysql-bin.001204', MASTER_LOG_POS=862149423;
start slave;
show slave status\G
断电导致从库故障
Last_SQL_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
查看错误 cat SRV-MYSQL-Slave.err
查看mysql主从密码cat master.info
Slave SQL: If a crash happens this configuration does not guarantee that the relay log info will be consistent, Error_code: 02021-08-17 16:28:10 4211 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.014017' at position 807538114, relay log './mysql-relay-bin.016471' position: 807538277
change master to master_host='mysqlmaster1.database.oigbuy.com',master_port=3306,master_user='repl_user',master_password='VzOkf65kfDIkHN5XUJJx',master_log_file='mysql-bin.014017',master_log_pos=807538114;
###################mysql设置远程密码报错 修改################
update userGroup set group = "sh_group,tj_dw_group,tj_admin_group,ferry_data_group" where user= 'root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group = "sh_group,tj_dw_group,tj_admin_group,ferry_data_group" where user= 'root' at line 1
flush privileges;
ALTER USER 'root'@'%' IDENTIFIED BY 'Oig#123456';
# 远程权限赋予
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'Oig#123456' WITH GRANT OPTION;