在mysql官网找到mysql5.7版本yum包,使用wget命令下载
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
安装mysql yum源
yum -y install mysql57-community-release-el7-10.noarch.rpm
更改mysql yum源配置,将需要安装得5.7版本的gpgchenck项改为0
![](https://img-blog.csdnimg.cn/img_convert/839f96fc3142c0c84a707a3fbd175808.png)
执行yum安装mysql
yum -y install mysql-community-server
启动mysql服务
systemctl start mysqld
查看mysql配置文件(因为是yum安装默认在/etc/目录下,配置文件里有mysql日志文件存放路径)
cat /etc/my.cnf
通过mysql日志文件查看初始登录密码
cat /var/log/mysqld.log |grep password
![](https://img-blog.csdnimg.cn/img_convert/350d8a37740434ed82b0251e342a7efc.png)
使用从日志中得到得密码登录数据库
mysql -u root -p
修改默认密码
alter user 'root'@'localhost' identified by '新密码';
flush privileges;
启用binlog日志(mysql默认是不启用的,需要自行启用)
10.1查看binlog状态
show variables like 'log_%';
![](https://img-blog.csdnimg.cn/img_convert/8eae9bd4fd6eb3bb2c6f162fb913e7d2.png)
10.2进入mysql配置文件在末尾增加如下配置
server-id=1
log_bin=mysql-bin #启用binlog功能
binlog_format=mixed #binlog的模式有三种,Row、Statement、Mixed,一般选mixed
expire_logs_days=7 #过期清理时间
max_binlog_size=1g #单个binlog文件最大值
#binlog_cache_size=10m #binlog缓存大小
#max_binlog_cache_size=512m #binlog最大缓存值
10.3重启mysql服务
systemctl restart mysqld
10.4进入数据库查看binlog状态
mysql -uroot -p
show variables like 'log_%';
show master logs; #(查看当前的binlog文件)
![](https://img-blog.csdnimg.cn/img_convert/3680de3bdbaed60ee71922f86df5cae2.png)
10.5查找binlog文件所在路径
find / -name mysql-bin*
![](https://img-blog.csdnimg.cn/img_convert/703a0d39ec8d194afe92f5b572127a75.png)