1.下载MySQL官方的 Yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2.安装 Yum Repository
yum -y install mysql57-community-release-el7-10.noarch.rpm
3 使用 yum 安装 MySQL
yum -y install mysql-community-server
若出现错误
Public key for mysql-community-libs-compat-5.7.41-1.el7.x86_64.rpm is not installed
Failing package is: mysql-community-libs-compat-5.7.41-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
解决方法
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
然后继续安装mysql的服务:
yum install mysql-server
安装成功
4 启动MySQL
systemctl start mysqld.service
5 查看mysql运行状态
6 获取 root 用户的密码
grep "password" /var/log/mysqld.log
7 进入数据库,使用刚才获取到的密码登录
mysql -u root -p
8 设置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Abc123456.';
9 添加root用户远程访问数据库
grant all on *.* to root@'%' identified by 'Abc123456.';
10 刷新访问权限的设置
flush privileges;
11 重启MySQL服务
systemctl restart mysqld.service
12 开启 mysql 的 binlog
- 修改 /etc/my.cnf
vim /etc/my.cnf
[mysqld]
#binlog⽇日志存放路路径】
log-bin=/var/lib/mysql/mysql-bin
#⽇日志中会记录成每⼀一⾏行行数据被修改的形式】
binlog-format=ROW
#指定当前机器器的服务ID(如果是集群,不不能重复)】
server_id=1
- 重启 mysql
systemctl restart mysqld.service
- 进入MySQL控制台,验证binlog是否打开
show variables like '%log_bin%';
4. 进入指定的 binlog 路径查看是否生产 binlog
cd /var/lib/mysql/