下载
```
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
```
解压
```
tar xf MySQL-5.6.44-1.el7.x86_64.rpm-bundle.tar
```
安装
```
yum install-y *.rpm
```
默认安装位置:/var/lib/mysql
报错信息:
```2019-08-30T11:18:22.976635Z 0 [Warning] Can‘t create test file /mydata/mysql/localhost.lower-test
2019-08-30T11:18:22.976687Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.27) starting as process 2788...2019-08-30T11:18:22.980289Z 0 [Warning] Can‘t create test file /mydata/mysql/localhost.lower-test
2019-08-30T11:18:22.980338Z 0 [Warning] Can‘t create test file /mydata/mysql/localhost.lower-test
解决办法:setenforce 0 #关闭防火墙
```
重置密码
```
默认密码:
grep‘pass‘ /var/log/mysqld.log
mysql_secure_installation
输入root密码
是否要修改密码
是否要修改root密码(大小写、数字、特殊字符)
是否要删除匿名用户
是否禁止root远程登录
是否要删除test数据库
是否要刷新表的权限
```
密码校验规则
```
设置密码的校验规则
mysql> set global validate_password_policy=0;
0 校验级别最低,只校验密码的长度,长度可以设定1必须包括大写字母、小写字母、数字、特殊字符2必须满足上面两条,并追加,对于密码中任意连续的4个(或者4个以上) 字符不能是字典中的单词
mysql> set global validate_password_length=3; 修改密码的最短长度
```
创建用户
```
create user‘username‘@‘ip‘ identified by ‘password‘;
全部ip的话则是%```
查看权限
```
show grants;
```
用户授权
```
mysql> grant all on *.* to ‘root‘@‘%‘ identified by ‘1234‘;
Query OK, 0 rows affected,1 warning (0.00sec)
mysql>flush privileges;
Query OK, 0 rows affected (0.00sec)
```
mysql主从
主服务器上配置如下(/etc/my.cnf)
```
server-id=1设置id
log-bin=/mydata/log/master-bin 启动binlog日志
sync_binlog= 1确保主从复制事务安全
```
主服务器执行如下sql
```
mysql> grant replication slave on *.* to ‘slave‘@‘192.168.21.131‘ identified by ‘1234‘;
Query OK, 0 rows affected,1 warning (0.00sec)
mysql>flush privileges;
Query OK, 0 rows affected (0.01sec)
show master status\G
```
从服务配置如下:
```
server-id =12relay_log=/mydata/log/slave-log
sync_binlog= 1read-only=ON
```
从服务器执行如下sql
```
CHANGE MASTER TO
MASTER_HOST=‘master2.example.com‘,
MASTER_USER=‘replication‘,
MASTER_PASSWORD=‘password‘,
MASTER_PORT=3306,
MASTER_LOG_FILE=‘master2-bin.001‘,
MASTER_LOG_POS=4,
MASTER_CONNECT_RETRY=10; #监控主服务器的时间#连接主库
change master to master_host=‘192.168.21.128‘,master_user=‘slave‘,master_password=‘1234‘;#启动进程
start slave;#查看状态
show slave status\G
```
问题:
```
Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different forreplication to work.
解决办法:
rm-rf /mydata/mysql/auto.cnf
systemctl restart mysqld
```
Linux-mysql主从复制
标签:host 匿名用户 change adb test 日志 col relay_log 0 rows
本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉
本文系统来源:https://www.cnblogs.com/sun-10387834/p/12785913.html