1.官网下载mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar,解压到 /usr/local/mysql/ 目录下;
2.依次安装mysql组件:
# 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-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
如果有报错如:
依赖检测失败:
mysql-community-common(x86-64) >= 5.7.9 被 mysql-community-libs-5.7.19-1.el7.x86_64 需要
mariadb-libs 被 mysql-community-libs-5.7.19-1.el7.x86_64 取代
则表示该依赖已存在,则删除以前依赖,重新安装,删除命令为:
# rpm -e mysql-libs
3.启动服务:
# systemctl start mysqld.service
查看状态:
# systemctl status mysqld.service
4.修改密码:
5.7版本以后,安装mysql后默认生成密码,密码在/var/log/mysqld.log文件中,
命令搜索:#grep ‘temporary password‘ mysqld.log
然后登陆:#mysql -uroot -p
输入密码后,进入mysql,修改密码:
mysql> use mysql;
mysql> alter user ‘root‘@‘%‘ identified by ‘password_123‘;
mysql> exit;
4.navicat连接测试:
正确输入连接信息后,可能会出现一下问题:
(1)error 1130-host ‘192.168.*.*’ is not allowed to connect to this MySql server.
解决:该mysql服务不允许远程连接。进入mysql
mysql> use mysql;
mysql> alter user set host=‘%‘ where user = ‘root‘;
mysql>select host,user from user;
mysql>flush privileges;
mysql>exit;
(2)error 1251 client does not support authentication protocol requested by server.
解决:root账户默认的加密方式是caching_sha2_password;很多客户端工具不支持这种加密认证方式,连接的时候就会报这种错。
mysql> use mysql;
mysql> alter user ‘root‘@‘%‘ identified by ‘password_123‘ password expire never;
mysql> alter user ‘root‘@‘%‘ identified with mysql_native_password by ‘password_123‘;
mysql> flush privileges;
mysql> exit;
重启mysql服务,再次连接,成功。
原文地址:https://www.cnblogs.com/li-jing/p/10695394.html