最近在阿里云服务器上安装了mysql5.7+workench组合,出现了root账户无法登录,错误提示如下:
Cannot Connect to Database Server
Your connection attempt failed for user 'root' from your host to server at localhost:3306:
Access denied for user'root'@localhost'
后面查了一下是由于mysql的加密方式改变,而与workbench没有统一而引起的。以下是解决方法:
在mysql终端输入:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your password';
FLUSH PRIVILEGES;
前一句是更改加密方式为旧式的:mysql_native_password,然后刷新配置。则能正常登陆。