mysql无法远程访问?
用Navicat链接虚拟机里的Mysql,死活连不上不服,气死 ==。结果一查发现是虚拟机里的MySQL远程链接需要打开,上网一搜怎么说的都有。我将踩过的坑发出来,希望对跟我一样问题的小白有点帮助。
'''
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
重启服务;
'''
。。。。。。接下来重启完后就可以登陆了。。