卸载MariaDB
- yum remove mariadb
- rpm -qa | grep mariadb
- rpm -e mariadb-libs-5.5.52-1.el7.x86_64 --nodeps
- rm -f /etc/my.cnf
- rm -rf /var/lib/mysql/
安装MySQL
- 复制mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar到虚拟机
(也可以使用wget
直接下载
https://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar
) - tar xvf mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar
- rpm -ivh mysql-community-common-8.0.15-1.el7.x86_64.rpm
- rpm -ivh mysql-community-libs-8.0.15-1.el7.x86_64.rpm
- rpm -ivh mysql-community-client-8.0.15-1.el7.x86_64.rpm
- rpm -ivh mysql-community-server-8.0.15-1.el7.x86_64.rpm
启动服务
- mysqld --initialize
- chown mysql:mysql /var/lib/mysql -R
- systemctl start mysqld.service
- systemctl enable mysqld
修改初始root密码
- cat /var/log/mysqld.log | grep password
2019-03-30T13:49:04.059788Z 5 [Note] [MY-010454] [Server]
A temporary password is generated
for root@localhost: d_tkTj3l1*:k
- mysql -u root -p
[root@localhost neusoft]# mysql -u root -p
Enter password: d_tkTj3l1*:k
- 重置密码为root
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
远程访问授权
- 进入mysql
- create user 'root'@'%' identified with mysql_native_password by 'root';
- grant all privileges on *.* to 'root'@'%' with grant option;
- flush privileges;
修改加密规则(可以省略)
- ALTER USER 'root'@'localhost' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER;
- flush privileges;
使用Sqlyog连接
启用日志
- 进入mysql命令行:
mysql -u root -p
- 查询日志状态:
show variables like 'general_log%';
- 开启日志:
set global general_log = 'on';
- 使用
tail -f 日志文件
,监控日志的变化
- end -