bind-address如果是127.0.0.1,mysql只接受localhost,不接受远程连接

来源:这里教程网 时间:2026-03-01 16:44:53 作者:

bind-address如果是127.0.0.1,mysql只接受localhost,不接受远程连接。在bind-address后面增加远程访问IP地址或者禁掉这句话就可以让远程机登陆访问了。在配置文件里面加入bind-address    = 127.0.0.1,然后重新启动,可以看到下面监听地址的变化。

root@scutech:~# netstat -plunt|grep 3306
tcp        0      0 127.0.0.1:33062         0.0.0.0:*               LISTEN      18408/mysqld        
tcp6       0      0 :::13306                :::*                    LISTEN      25061/mysqld        
tcp6       0      0 :::33060                :::*                    LISTEN      18408/mysqld        
tcp6       0      0 :::3306                 :::*                    LISTEN      18408/mysqld        
root@scutech:~# service mysql restart
root@scutech:~# netstat -plunt|grep 3306
tcp        0      0 127.0.0.1:33062         0.0.0.0:*               LISTEN      18622/mysqld        
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      18622/mysqld        
tcp6       0      0 :::13306                :::*                    LISTEN      25061/mysqld        
tcp6       0      0 :::33060                :::*                    LISTEN      18622/mysqld

这个时候连接会提示:

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.17.40' (111)

如果地址是 0.0.0.0, 服务接受所有IPV4的接口;如果地址是 ::, t服务接受所有IPV4和 IPv6 的接口;

相关推荐