MySQL登录时出现 Access denied for user 'root'@'xxx.xxx.xxx.xxx' (using password: YES) 的原因及解决办法

【解决办法】
1. 先用localhost登录

首先进入DOS界面,cd 你的mysql的安装路径。比如:cd C:\Program Files\MySQL\MySQL Server 5.6\bin

然后在 > 后输入以下:

mysql -u root -p

回车:
Enter password: 

输入正确的密码后,会出现welcome的欢迎语。


2. 然后执行授权命令,输入以下(其中123456为你新设定的密码):
mysql> grant all privileges on *.* to root@'%' identified by '123456';
Query OK, 0 rows affected (0.07 sec)
3. 退出再试
mysql> quit
Bye


4.再试,输入远程IP进行登录:
mysql -u root -h 150.168.xx.xx -p

回车,输入刚才设定的密码:
Enter password: 

出现以下欢迎语,表明成功了。应该可以远程连接了。
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.33 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> 

你可能感兴趣的:(技术支持,mysql)