1 问题描述
- xShell连接服务器,可以正常使用账户密码登录mysql
- navicat连接报错,有时后面的IP甚至都不是你填写的IP:
error no. 1045 access denied for user 'root'@'*****' (using password:YES)
- 近期可能才刚重启mysql服务
2 问题解决
出现此现象多半是应该没给root授权,接下来就教你如果给root用户授予远程访问权限
[root@VM_0_12_centos ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.30 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";
Query OK, 0 rows affected, 1 warning (0.09 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)