MySQL密码正确却无法本地登录-1045
MySQL密码正确却无法本地登录-1045Accessdeniedforuser'root'@'localhost'(usingpassword:YES
MySQL密码正确却无法本地登录
报错如下:
ERROR1045(28000):Accessdeniedforuser‘root‘@‘localhost‘(usingpassword:YES)
解决方法:
1、在启动mysql的参数中加入跳过密码问题方式,如下:
vim/etc/my.cnf
并在[mysql]下面加上skip-grant-tables,
这个用于跳过密码问题,但是这并不能彻底解决。
2、重启mysql服务
本人用的是Linux系统的Mysql,语句如下:
查看端口号:
psaux|grepmysqld
查看状态:
systemctlstatusmysqld
重启mysql服务
systemctlrestartmysqld
尝试连接:
mysql-uroot-p123456
输入密码,刚才已经设置跳过密码了可忽略
操作步骤如下:
[root@localhost~]#mysql-uroot-p123456 mysql>usemysql Databasechanged mysql>selectuser,host,passwordfromuserwhereuser='root'; +------+-----------------------+-------------------------------------------+ |user|host|password| +------+-----------------------+-------------------------------------------+ |root|%|*00A51F3F48415C7D4E8908980D443C29C69B60C9| |root|localhost.localdomain|*00A51F3F48415C7D4E8908980D443C29C69B60C9| |root|127.0.0.1|*00A51F3F48415C7D4E8908980D443C29C69B60C9| |root|::1|*00A51F3F48415C7D4E8908980D443C29C69B60C9| +------+-----------------------+-------------------------------------------+ 4rowsinset(0.02sec) mysql>updateusersethost='localhost'whereuser='root'andhost='%'; QueryOK,1rowaffected(0.01sec) Rowsmatched:1Changed:1Warnings:0 mysql>flushprivileges; QueryOK,0rowsaffected(0.03sec) mysql>quit Bye
OK,退出mysql,重启mysql就解决问题了
前后对比一下:
[root@localhost~]#mysql-uroot-p mysql>usemysql; Databasechanged mysql>selectuser,host,passwordfromuserwhereuser='root'; +------+-----------------------+-------------------------------------------+ |user|host|password| +------+-----------------------+-------------------------------------------+ |root|localhost|*00A51F3F48415C7D4E8908980D443C29C69B60C9| |root|localhost.localdomain|*00A51F3F48415C7D4E8908980D443C29C69B60C9| |root|127.0.0.1|*00A51F3F48415C7D4E8908980D443C29C69B60C9| |root|::1|*00A51F3F48415C7D4E8908980D443C29C69B60C9| +------+-----------------------+-------------------------------------------+ 4rowsinset(0.00sec) mysql> OK!
总结
以上所述是小编给大家介绍的MySQL密码正确却无法本地登录-1045Accessdeniedforuser''root''@''localhost''(usingpassword:YES,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。