解決mysql不能遠(yuǎn)程訪問的辦法(原創(chuàng))

本方法在路由上測(cè)試,其他系統(tǒng)應(yīng)該一樣

[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]#
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,578評(píng)論 19 139
  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,099評(píng)論 25 709
  • 第二章 物理層 頻分復(fù)用:頻分復(fù)用的用戶在同樣的時(shí)間占用不同的帶寬資源(頻率帶寬) 時(shí)分復(fù)用:時(shí)分復(fù)用的用戶在不同...
    PramaWells閱讀 4,026評(píng)論 1 3
  • 妹妹昨天吃飽睡好去游泳,可開心了。 游泳回來,就開始打瞌睡。媽媽喂母乳,結(jié)果小家伙睡了一下直哭,餓得超級(jí)清醒。然后...
    橙橙mama閱讀 288評(píng)論 0 0
  • 仙本那(Semporna)是馬來西亞東部沙巴州的一個(gè)小鎮(zhèn),因?yàn)槭澜鐫撍秆趴艘练颉焖雇幸痪洹癎host o...
    小漫巡天下閱讀 446評(píng)論 0 0

友情鏈接更多精彩內(nèi)容