1 官网下载mysql离线rpm包
下载地址:https://dev.mysql.com/downloads/mysql/
2 将下载的tar包上传到/opt/rpm/mysql目录
3 删除CentOS自带的mariadb
说明:不删的话mysql会和mariadb冲突
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs
4 在/opt/rpm/mysql目录解压tar包
cd /opt/rpm/mysql/ tar -xvf mysql-8.0.32-1.el7.x86_64.rpm-bundle.tar
5 安装离线rpm包
rpm -ivh *.rpm --force --nodeps
6 初始化数据库&授权mysql用户访问
mysqld --initialize --console
chown -R mysql:mysql /var/lib/mysql/
7 启动mysql服务
systemctl start mysqld
8 查看临时密码
cat /var/log/mysqld.log
9 登录mysql客户端
mysql -u root -p
粘贴密码回车
10 设置root用户的密码
alter USER 'root'@'localhost' IDENTIFIED BY 'Root@123456'; #需要包含大小写字母、数字、符号,我试了好多次才行- -
11 授权root用户可以远程访问
show databases;
use mysql; select host, user, authentication_string, plugin from user;
update user set host = "%" where user='root';
select host, user, authentication_string, plugin from user;
flush privileges; #刷新权限
12 用Navicat远程连接
大功告成!
13 参考
https://www.cnblogs.com/quchunhui/p/11115339.html
标签:8.0,--,32,离线,user,mysql,root,rpm From: https://www.cnblogs.com/whjblog/p/17192502.html