mysql数据库登录时出现报错

解决方法:
[root@localhost local]# vim /etc/my.cnf ##修改etc下面的配置文件my.cnf
在底行加入
skip-grant-tables ##免密登录;wq保存
重启服务
[root@localhost local]# systemctl restart mysqld
这时用mysql -uroot -p去登录是不需要密码的

更改以root身份登录的密码,这边密码设置为123456
mysql> update mysql.user set authentication_string=password('123456') where user='root';
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges; ##刷新数据库
Query OK, 0 rows affected (0.00 sec)
退出数据库;再次修改/etc/my.cnf文件,将添加的免密登录去掉
重启服务后,再次登录数据库


本文介绍了一种在遇到MySQL登录报错时的解决方案,通过修改my.cnf配置文件实现免密登录,进而更新root用户的密码。完成操作后,需重新配置my.cnf并重启服务。
1723

被折叠的 条评论
为什么被折叠?



