远程无法连接mysql
解决方法:
1、在服务器登录数据
mysql -uroot -hlocalhost -P3306 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 5.6.39 MySQL Community Server (GPL) Copyright (c) 2000, 2018, 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.
2、选择mysql数据库
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
3、更新root密码
mysql> UPDATE user SET Password=PASSWORD(‘newpassword‘) where USER=‘root‘; Query OK, 4 rows affected (0.01 sec) Rows matched: 5 Changed: 4 Warnings: 0
4、刷新权限
mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)