mysql数据库明明密码正确却本机登录不了的解决方法
工作中经常会遇到使用mysql数据库的时候密码明明是正确的,但是mysql -uroot -p123456提示“ERROR 1044 (42000): Access denied for user ‘’@‘localhost’ to database ‘password’”,原因是因为myslq库中的user表缺少一个root指向 localhost的数据项,只有一个root指向host,所以无法使root账户登录mysql。
解决方法:使用–skip-grant-tables
/usr/bin/mysqld_safe --skip-grant-tables
然后再使用 mysql即可跳过密码登录
而后再输入:
update user set host='localhost' where user='root' and host='%';
flush privileges;
重启mysql后即可。
注:可在myql命令行中输入use mysql;select user,host,password from user where user=‘root’;查看是否有localhost。
当遇到MySQL提示'ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'password''时,问题可能在于user表缺少root到localhost的数据项。解决方法是使用--skip-grant-tables启动MySQL,然后更新user表,将root用户的host设置为localhost,再刷新权限。重启MySQL后即可正常登录。


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



