解决ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:

本来是没有这个问题的,但是因为一次修改了远程登录的权限:

1  改表法

可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"

mysql -u root -pvmwaremysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>select host, user from user;

 

导致了:

 

# mysql -uroot -p

 

Enter password: 

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

 

后来在网上看了写资料,自己猜了一下,也许是因为要加入参数-h的缘故的把:

试了一下:

# mysql -uroot -h 你的ip -p 比如ip是192.168.66.11 那么就是:mysql -uroot -h 192.168.66.22 -p

 

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 17

Server version: 5.5.48 MySQL Community Server (GPL)

 

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql> 

==========Over

 

猜你喜欢

转载自rayfuxk.iteye.com/blog/2287904
今日推荐