本地Navicat Premium连接数据库报错
Can't connect to MySQL server on '127.0.0.1' (61)
先进行以下尝试

1.本地连接虚拟机的ip

telnet 192.168.33.11
//出现一下错误
elnet: connect to address 192.168.33.11: Connection refused
telnet: Unable to connect to remote host

2.虚拟机安装telnet

sudo apt-get install telnetd
sudo netstat -a | grep telnet
tcp        0      0 *:telnet                *:*                     LISTEN
本机再次尝试 telnet 192.168.33.11 已经可以连接..

3.本机尝试

telnet 192.168.33.11 3306

telnet: connect to address 192.168.33.11: Connection refused
telnet: Unable to connect to remote host

//虚拟机查看端口
netstat -an|grep 3306
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
把
bind-address            = 127.0.0.1
修改 
bind-address            = 0.0.0.0
sudo service mysql restart
//再次虚拟机查看端口
netstat -an|grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN

Navicat Premium 连接错误
Access denied for user 'root'@'192.168.33.1' (using password: YES)

虚拟机进入 mysql -uroot -p123456
grant all privileges on *.* to root@'%' identified by '123456';
//表示root用户可以在任何ip都可以访问任何库的任何对象,密码是123456生产上,按实际情况而定。
flush privileges;//刷新权限
执行上面命令再次尝试已经可以连接

关注友儿不迷路

Last modification:April 27th, 2020 at 10:30 am
如果觉得我的文章对你有用,请随意赞赏