首页 文章

2003年 - 可以't connect to MySQL server on ' localhost'(10038)

提问于
浏览
2

我在我的ubuntu虚拟机中安装了mysql服务器,然后我使用Navaicat for Mysql来连接mysql,但失败了 . Navicat for Mysql安装在Windows 7上,Navicat版本是11.0.10,企业版mysql安装在我的虚拟机上,系统是Ubuntu 12,当我连接mysql服务器时,它返回:
enter image description here

我的navicat连接配置:
enter image description here

我尝试了几种方法,包括使用命令:授予所有权限 . 'root' @ '%'由'passwd'用授权选项标识我关闭ubuntu的防火墙使用:ufw disable我hava也关闭了Windows 7的防火墙,ubuntu服务器的端口3306的状态是:
enter image description here

iptable规则是这样的:
enter image description here

mysql.user表是这样的:
enter image description here

但仍然,navicat给了我错误:2003 - 无法连接到'localhost'上的mysql服务器(10038)

有人可以帮帮我吗?谢谢!

3 回答

  • 11

    我解决了这个问题 . 在我的/etc/mysql/my.cnf中,命令绑定locahost地址,如下所示:bind-address = 127.0.0.1,只需在它之前添加一个# . 现在我可以顺利连接到mysql服务器了 .

  • 0

    尝试在viritual机器配置中添加 Port Forwarding RuleSettings > Network > Adapter1 > Advanced > "Port Forwarding"

  • 0
    • 在路径 /etc/mysql/ 中查找 my.cnf 文件

    • 查找 bind-address = 127.0.0.1 并将其评论如下:

    #bind-address = 127.0.0.1

    • 重启MySQL

    • 现在我们遇到了不允许连接到这个MySQL服务器的问题,因此我们需要继续

    • 使用以下MySQL命令:

    grant all PRIVILEGES on database_name.* to user_name@'%' identified by 'user_password';
    
    • 检查 information_schema 数据库中的 user_privileges 表,确保已在表中添加 user_name .

    • 使用 user_name 从本地登录到远程MySQL

相关问题