一、远程登录mysql出错,比如:
# mysql -u root -h 192.168.9.9 -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'192.168.9.9' (using password: YES)
【解决办法】
1. 先用localhost登录
# mysql -u root -p
Enter password:
2. 执行授权命令
mysql> grant all privileges on *.* to root@'%' identified by '123';
Query OK, 0 rows affected (0.07 sec)
3. 退出再试
mysql> quit
Bye
再试登录:
# mysql -u root -h 192.168.9.9 -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出错,比如:
“Access denied for user 'ODBC'@'localhost' (using password:NO)”也是这个。
解决方案:
如果是5.7版本之后的话:
password字段改成了
authentication_string
所以更改语句替换为update mysql.user set authentication_string=password('654321') where user='root' ;即可