用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
重啟服務;
'''
。。。。。。接下來重啟完后就可以登陸了。。