错误提示:
物理机navicat连接ubuntu的mysql数据库10061错误:can't connect to server on “192.168.0.145”
解决办法:
1. 首先排查防火墙设置,我这里是关闭状态:sudo ufw status
2. mysql数据库新增任意ip地址可以访问:
3. 查看数据库服务是否有启动,发现有启动
systemctl status mysql
4. 查看数据库端口是否是3306,结果是3306
show global variables like 'port';
5. 查看root用户权限,是否有开放远程连接,看了是有开放,%代表允许远程
select user,host from mysql.user;
1.mysql>grant all privileges on . to 'root'@'%' identified by 'root';
(%) 表示所有ip
第1个root表示账户
第2个root表示密码
2.mysql>flush privileges;
3.停止并重启mysql服务。
6. 查看修改配置文件mysqld.cnf
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 127.0.0.1注释掉(即在行首加#),如下:
代码如下:
Instead of skip-networking the default is now to listen only on
localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
7. 然后重启服务即可访问了
service mysql restart