navicat连接ubantu22里的mysql
错误:SHH Tunnel:Server does not support…
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 |
+-----------+------------------+
| localhost | debian-sys-maint |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
5 rows in set (0.00 sec)
mysql> update user set host='%' where user='root';#root账号的host修改为可以访问所有主机
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select host,user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| localhost | debian-sys-maint |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
+-----------+------------------+
5 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> grant all on *.* to 'root'@'%';#授权
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
重启MySQL服务:/etc/init.d/mysql restart
如果遇到:cannot connect to mysql server 10061
1.开放3306端口:bash sudo ufw allow 3306
2.查看端口是否开放:sudo netstat -lntp | grep 3306
如果ip是127.0.0.1:3306,需要修改bind_address为0.0.0.0
修改/etc/mysql/mysql.conf.d下的mysqld.cnf,然后重启mysql
重启:service mysql restart
再次查看是否修改成功:
3.关闭防火墙:sudo ufw status
4.如果以上操作还不成功,查看虚拟机的网卡设置,是否是桥接模式,设置为桥接模式,最后测试连接,连接成功。