1、删除原有系统mariadb
# rpm -qa|grep mariadb
# rpm -e --nodeps mariadb-libs
2.在dev.mysql.com/downloads/repo/yum/选择为Red Hat Enterprise Linux 7 / Oracle Linux 7 ,把os的版本选择为all。
直接下载mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar,所有的rpm包都在里面
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-devel-8.0.15-1.el7.x86_64.rpm |
rpm -ivh mysql-community-libs-compat-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 |
rpm -ivh mysql-community-test-8.0.15-1.el7.x86_64.rpm |
rpm -ivh mysql-community-embedded-compat-8.0.15-1.el7.x86_64.rpm |
3、重置数据库root密码为123@456.Com
# systemctl stop mysqld.service
# vim /etc/my.cnf 添加 skip-grant-tables
# systemctl start mysqld.service
# mysql -u root -p
flush privileges;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123@456.Com';
quit;
# systemctl stop mysqld.service
# vim /etc/my.cnf 去除 skip-grant-tables
加入自启动 # systemctl enable mysqld
4、尝试连接失败
无法连接,因为root无权限,修改为所有IP都可访问即可
# mysql -u root -p登录数据库
use mysql; |
show tables; |
select user, host, plugin, authentication_string from user; |
UPDATE mysql.user SET host = '%' WHERE user = 'root'; |
flush privileges; |
5、尝试连接成功
待续。。。。。。
# mysql -u root -p 进入数据库 |
CREATE DATABASE GwHr; 创建数据库 |
show global variables like 'port';查看默认端口 |