mysql無法遠程訪問?

用Navicat鏈接虛擬機里的Mysql,死活連不上不服,氣死 ==。結果一查發(fā)現(xiàn)是虛擬機里的MySQL遠程鏈接需要打開,上網(wǎng)一搜怎么說的都有。我將踩過的坑發(fā)出來,希望對跟我一樣問題的小白有點幫助。


'''

MySQL -u root -p ..... //登陸mysql

2. MySQL> select host,user from mysql.user; //

+-----------+------------------+

| host? ? ? | user? ? ? ? ? ? |

+-----------+------------------+

| %? ? ? ? | root? ? ? ? ? ? |

| localhost | debian-sys-maint |

| localhost | mysql.session? ? |

| localhost | mysql.sys? ? ? ? |

| localhost | root? ? ? ? ? ? |

+-----------+------------------+

5 rows in set (0.00 sec)

3. mysql> delete from mysql.user where host='localhost' and user='roo;

Query OK, 1 row affected (0.18 sec)

4. mysql> select host,user from mysql.user;

+-----------+------------------+

| host? ? ? | user? ? ? ? ? ? |

+-----------+------------------+

| %? ? ? ? | root? ? ? ? ? ? |

| localhost | debian-sys-maint |

| localhost | mysql.session? ? |

| localhost | mysql.sys? ? ? ? |

+-----------+------------------+

4 rows in set (0.01 sec)

5. mysql> exit;//退出MySQL

Bye

ymxdgyx@ubuntu:/$ cd /etc/mysql/

ymxdgyx@ubuntu:/etc/mysql$ ll

總用量 40

drwxr-xr-x? 4 root root? 4096 11月? 6 19:16 ./

drwxr-xr-x 136 root root 12288 12月 12 14:29 ../

drwxr-xr-x? 2 root root? 4096 11月? 6 19:15 conf.d/

-rw-------? 1 root root? 317 11月? 6 19:16 debian.cnf

-rwxr-xr-x? 1 root root? 120 10月 18 23:22 debian-start*

lrwxrwxrwx? 1 root root? ? 24 11月? 6 19:15 my.cnf -> /etc/alternives/my.cnf

-rw-r--r--? 1 root root? 839 1月? 22? 2017 my.cnf.fallback

-rw-r--r--? 1 root root? 682 2月? 4? 2017 mysql.cnf

drwxr-xr-x? 2 root root? 4096 11月? 6 19:16 mysql.conf.d/

ymxdgyx@ubuntu:/etc/mysql$ vim mysql.cnf #這里我只留下了 !mysqld.cnf? !mysqld_safe_syslog.cnf兩個服務,其他都注釋掉了 ==?。。?!

ymxdgyx@ubuntu:/etc/mysql$ cd mysql.conf.d/

ymxdgyx@ubuntu:/etc/mysql/mysql.conf.d$ ll

總用量 16

drwxr-xr-x 2 root root 4096 11月? 6 19:16 ./

drwxr-xr-x 4 root root 4096 11月? 6 19:16 ../

-rw-r--r-- 1 root root 3028 2月? 4? 2017 mysqld.cnf

-rw-r--r-- 1 root root? 21 2月? 4? 2017 mysqld_safe_syslog.cnf

ymxdgyx@ubuntu:/etc/mysql/mysql.conf.d$ vim mysqld

mysqld.cnf? ? ? ? ? ? ? mysqld_safe_syslog.cnf

ymxdgyx@ubuntu:/etc/mysql/mysql.conf.d$ vim mysqld

mysqld.cnf? ? ? ? ? ? ? mysqld_safe_syslog.cnf

ymxdgyx@ubuntu:/etc/mysql/mysql.conf.d$ sudo vim mysqld.cnf

[sudo] ymxdgyx 的密碼:

ymxdgyx@ubuntu:/etc/mysql/mysql.conf.d$ service mysql restart

重啟服務;

'''

。。。。。。接下來重啟完后就可以登陸了。。


最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

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

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