解决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阅读 134,973评论 19 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,455评论 25 708
  • 第二章 物理层 频分复用:频分复用的用户在同样的时间占用不同的带宽资源(频率带宽) 时分复用:时分复用的用户在不同...
    PramaWells阅读 3,870评论 1 3
  • 妹妹昨天吃饱睡好去游泳,可开心了。 游泳回来,就开始打瞌睡。妈妈喂母乳,结果小家伙睡了一下直哭,饿得超级清醒。然后...
    橙橙mama阅读 240评论 0 0
  • 仙本那(Semporna)是马来西亚东部沙巴州的一个小镇,因为世界潜水之父雅克伊夫·库斯托一句“Ghost o...
    小漫巡天下阅读 360评论 0 0