开发者社区 问答 正文

无法连接到数据库服务器(MySQL Workbench)?mysql

你能帮我解决这个问题吗?

当我尝试单击Mysql工作台中数据库菜单下的“查询数据库”时。它给我一个错误:

Cannot Connect to Database Server

Your connection attempt failed for user 'root' from your host to server at 127.0.0.1:3306:Can't connect to mysql server on '127.0.0.1'(10061)

Please:

  1. Check that mysql is running on server 127.0.0.1
  2. Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed)
  3. Check the root has rights to connect to 127.0.0.1 from your address (mysql rights define what clients can connect to the server and from which machines)
  4. Make sure you are both providing a password if needed and using the correct password for 127.0.0.1 connecting from the host address you're connecting from

展开
收起
保持可爱mmm 2020-05-17 11:20:01 1231 分享 版权
1 条回答
写回答
取消 提交回答
  • 该问题可能是由于在升级到ubuntu 16.04时未设置密码的情况下,默认情况下为root用户启用了套接字身份验证。

    解决方案是恢复到本机密码身份验证。您可以通过执行以下操作使用套接字身份验证登录到MySQL:

    sudo mysql -u root 登录后:

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; 它将恢复为本机(旧的默认)密码身份验证。

    现在,只要MySQL需要,就使用password作为密码。来源:stack overflow

    2020-05-17 11:20:37
    赞同 展开评论