我知道有类似的问题,但我没有find我正在寻找什么。 这是发生了什么,这有点奇怪:
[root@xxx xxx]# mysql -u profuser -ppwd -h 192.168.1.99 ERROR 1045 (28000): Access denied for user 'profuser'@'192.168.1.99' (using password: YES)
而192.168.1.99是我自己的IP。 但是,当我使用localhost或127.0.0.1 ,这是OK的:
[root@xxx xxx]# mysql -u profuser -ppwd -h 127.0.0.1 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 68 Server version: 5.0.45 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> bye [root@xxx xxx]# mysql -u profuser -ppwd -h localhost Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 69 Server version: 5.0.45 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
我发现这个问题,但没有帮助:
mysql> select host from user where user='profuser'; +--------------+ | host | +--------------+ | 127.0.0.1 | | 192.168.1.99 | | localhost | +--------------+
我加了我的IP,正如另一个问题所build议的那样。
密码哈希是否与新的用户/主机组合相匹配? 调整你的select语句: select host, password from user where user='profuser';
无论如何,你试图达到什么目的? 您正在添加-h 192.168.1.99标志; 在本地连接时不需要(如你所发现的)。 如果你想要通过networking连接,那么你需要一个用户规范,如'root'@'192.168.1.%'或'root'@'%' ,允许远程主机; 如果你只是做本地连接,那么你不需要-h 。
使用INSERT INTO mysql.user ...等查询手动添加主机时,必须发出FLUSH PRIVILEGES命令来应用更改。