数据库教程:MySQL密码正确却无法本地登录-1045

mysql密码正确却无法本地登录-1045 access denied for user (using password:yes mysql密码正确却无法本地登录 报错如下:

mysql密码正确却无法本地登录-1045 access denied for user (using password:yes

mysql密码正确却无法本地登录

报错如下:

error 1045 (28000): access denied for user ‘ (using password: yes)

解决方法:

1、在启动mysql的参数中加入跳过密码问题方式,如下:

vim /etc/my.cnf

并在[mysql]下面加上skip-grant-tables,

这个用于跳过密码问题,但是这并不能彻底解决。

2、重启mysql服务

本人用的是linux系统的mysql,语句如下:

查看端口号:

ps aux|grep mysqld

查看状态:

systemctl status mysqld

重启mysql服务

systemctl restart mysqld

尝试连接:

mysql -uroot -p123456

输入密码,刚才已经设置跳过密码了可忽略

操作步骤如下:

  [root@localhost ~]# mysql -uroot -p123456  mysql> use mysql  database changed  mysql> select user,host,password from user where user='root';  +------+-----------------------+-------------------------------------------+  | user | host | password |  +------+-----------------------+-------------------------------------------+  | root | % | *00a51f3f48415c7d4e8908980d443c29c69b60c9 |  | root | localhost.localdomain | *00a51f3f48415c7d4e8908980d443c29c69b60c9 |  | root | 127.0.0.1 | *00a51f3f48415c7d4e8908980d443c29c69b60c9 |  | root | ::1 | *00a51f3f48415c7d4e8908980d443c29c69b60c9 |  +------+-----------------------+-------------------------------------------+  4 rows in set (0.02 sec)    mysql> update user set host='localhost' where user='root' and host='%';  query ok, 1 row affected (0.01 sec)  rows matched: 1 changed: 1 warnings: 0    mysql> flush privileges;  query ok, 0 rows affected (0.03 sec)    mysql> quit  bye

ok,退出mysql,重启mysql就解决问题了

前后对比一下:

  [root@localhost ~]# mysql -uroot -p  mysql> use mysql;  database changed  mysql> select user,host,password from user where user='root';  +------+-----------------------+-------------------------------------------+  | user | host | password |  +------+-----------------------+-------------------------------------------+  | root | localhost | *00a51f3f48415c7d4e8908980d443c29c69b60c9 |  | root | localhost.localdomain | *00a51f3f48415c7d4e8908980d443c29c69b60c9 |  | root | 127.0.0.1 | *00a51f3f48415c7d4e8908980d443c29c69b60c9 |  | root | ::1 | *00a51f3f48415c7d4e8908980d443c29c69b60c9 |  +------+-----------------------+-------------------------------------------+  4 rows in set (0.00 sec)    mysql>   ok!

总结

以上所述是小编给大家介绍的mysql密码正确却无法本地登录-1045 access denied for user (using password:yes,希望对大家有所帮助

需要了解更多数据库技术:MySQL密码正确却无法本地登录-1045,都可以关注数据库技术分享栏目—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/dtteaching/821867.html

(0)
上一篇 2021年9月17日
下一篇 2021年9月17日

精彩推荐