无法连接到数据库服务器(MySQL Workbench)
您能帮我解决这个问题吗?
Could you help me solve this problem ?
当我尝试单击Mysql工作台中数据库菜单下的查询数据库"时.它给了我一个错误:
When I try to click "query database" under database menu in Mysql workbench. it gives me an error:
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
此问题很可能是由于在升级到ubuntu 16.04时未设置密码的情况下默认情况下为root用户启用了套接字身份验证.
The issue is likely due to socket authentication being enabled for the root user by default when no password is set, during the upgrade to ubuntu 16.04.
解决方案是恢复到本机密码身份验证.您可以通过执行以下操作使用套接字身份验证登录到MySQL:
The solution is to revert back to native password authentication. You can do this by logging in to MySQL using socket authentication by doing:
sudo mysql -u root
登录后:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
,它将恢复为本机(旧的默认)密码身份验证.
which will revert back to the native (old default) password authentication.
现在,只要MySQL要求,就使用密码作为密码.
Now use password as the password whenever required by MySQL.