mysql无法远程访问?

用Navicat链接虚拟机里的Mysql,死活连不上不服,气死 ==。结果一查发现是虚拟机里的MySQL远程链接需要打开,上网一搜怎么说的都有。我将踩过的坑发出来,希望对跟我一样问题的小白有点帮助。

MySQL -u root -p ….. //登陆mysql

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)

mysql> delete from mysql.user where host=’localhost’ and user=’roo;
Query OK, 1 row affected (0.18 sec)

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)

mysql> exit;//退出MySQL
Bye

ymxdgyx@ubuntu:/$ cd /etc/mysql/ //进入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 //重启mysql服务

然后再用navicat链接虚拟机的MySQL就可以链接上了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值