mysql问题记录

146 阅读1分钟

mysql 在登录时出现Access denied for user ‘root’@’localhost’ (using password: YES)

# 打开mysql配置文件
vim /etc/my.cnf
# 添加这句,跳过权限检查表,所有用户都拥有所有权限
skip-grant-tables
# 如果有设置密码,先注释掉密码
# 上面错误是有密码(using password:YES),没有密码的情况是(using password:NO) #password=xxx
# 重启mysql
systemctl restart mysql.service
# 先确认mysql去除密码正常运行
mysql –uroot –p
# 新开一个窗口
mysql
# 使用mysql表
use mysql;
# 更新密码
update user set authentication_string=password("123456") where user="root"; 
# 去除skip-grant-tables
# 重新启动mysql