panic: Error 1045 (28000): Access denied for user 'learngo'@'localhost' (using password: YES)
时间: 2023-11-20 22:58:15 浏览: 30
这个错误提示表明用户'learngo'在尝试使用密码登陆mysql时被拒绝了。可能的原因是密码错误或者该用户没有权限访问mysql。解决方案如下:
1. 确认密码是否正确,如果不确定可以尝试重置密码。
2. 确认该用户是否有访问mysql的权限,如果没有可以尝试授权该用户访问mysql。
以下是两种解决方案:
1. 重置密码
```shell
# 停止mysql服务
sudo service mysql stop
# 以跳过授权表的方式启动mysql
sudo mysqld_safe --skip-grant-tables &
# 进入mysql
mysql -u root
# 切换到mysql数据库
use mysql;
# 更新用户密码
update user set authentication_string=password('new_password') where user='learngo';
# 刷新权限
flush privileges;
# 退出mysql
exit;
# 停止mysql服务
sudo service mysql stop
# 以正常方式启动mysql
sudo service mysql start
```
2. 授权用户访问mysql
```shell
# 进入mysql
mysql -u root -p
# 输入密码
# 授权用户访问mysql
grant all privileges on *.* to 'learngo'@'localhost' identified by 'password';
# 刷新权限
flush privileges;
# 退出mysql
exit;
```