解决mysql不能远程访问的办法(原创)

本方法在路由上测试,其他系统应该一样

[RT-N14U /home/root]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, 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> 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

Database changed
mysql> select host,user from user;
+-----------+------+
| host      | user |
+-----------+------+
| 127.0.0.1 | root |
| localhost |      |
| localhost | root |
| rt-n14u   |      |
| rt-n14u   | root |
+-----------+------+
5 rows in set (0.00 sec)

mysql> update user set host = '%' where user = 'root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
mysql> select host,user from user;
+-----------+------+
| host      | user |
+-----------+------+
| %         | root |
| 127.0.0.1 | root |
| localhost |      |
| rt-n14u   |      |
| rt-n14u   | root |
+-----------+------+
5 rows in set (0.00 sec)

mysql> grant all privileges on *.* to 'root'@'%' identfied by 'admin' with grant optioERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresith grant option' at line 1
mysql>
mysql>
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'admin' WITH GRANT OPTI
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye
[RT-N14U /home/root]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[RT-N14U /home/root]# mysql -u -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, 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> exit
Bye
[RT-N14U /home/root]#

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 103,704评论 13 125
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 141,625评论 20 608
  • 第二章 物理层 频分复用:频分复用的用户在同样的时间占用不同的带宽资源(频率带宽) 时分复用:时分复用的用户在不同...
    PramaWells阅读 985评论 1 1
  • 妹妹昨天吃饱睡好去游泳,可开心了。 游泳回来,就开始打瞌睡。妈妈喂母乳,结果小家伙睡了一下直哭,饿得超级清醒。然后...
    橙橙mama阅读 31评论 0 0
  • 仙本那(Semporna)是马来西亚东部沙巴州的一个小镇,因为世界潜水之父雅克伊夫·库斯托一句“Ghost o...
    小漫巡天下阅读 113评论 0 0