1、出现密码yes,无法登陆——重置密码
vim /etc/my.cnf
添加skip-grant-tables
重新启动MySQL服务:systemctl restart mysqld.service
无密码登陆MySQL,重置密码:
use mysql;
update user set password=password("你的新密码") where user="root";
或:update user set authentication_string=password('新密码') where user='root' and Host='localhost';
更新权限:flush privileges;
如果在执行该步骤的时候出现ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement 错误。则执行下 flush privileges 命令,再执行该命令即可
2、如果出现主机无法连接虚拟机上的MySQL服务器:
原因:没有给远程连接授权
GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
其中user,passwoed是自己的mysql的数据库用户名和密码
3、如果提示ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
这是系统提示需要重置密码
alter user user() identified by "admin@123";
4、经过第二步,远程连接还出现10060错误——防火墙没放行
查数据库允许登陆的IP与用户:select host,user from user;
关闭防火墙:(1) systemctl stop iptables.service
若在关闭防火墙时出现:
解决方法:
(2) service firewalld stop
5、连接