ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO) 阿里云服务器发布

本文档详细介绍了在MySQL 5.7及以上版本中,由于`password`字段被替换为`authentication_string`,如何正确地更改root用户的密码。步骤包括停止MySQL服务,启动带有特定选项的mysqld_safe,用root用户登录,更新`authentication_string`字段,刷新权限,重启MySQL服务,最后使用新密码登录验证。

止mysql数据库

/etc/init.d/mysqld stop 

#2.执行如下命令

mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 

#3.使用root登录mysql数据库

mysql -u root mysql 

#4.更新root密码

mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';

修改密码是报错
ERROR 1054 (42S22): Unknown column ‘password’ in 'field list’

因为mysql-5.7及以上版本已没有password字段,已将password字段修改为authentication_string字段

解决方法:
将password修改为authentication_string

update user set authentication_string=password('you new password') where user='root';

#5.刷新权限 

mysql> FLUSH PRIVILEGES; 

#6.退出mysql

mysql> quit 

#7.重启mysql

/etc/init.d/mysqld restart 

#8.使用root用户重新登录mysql

mysql -uroot -p 

Enter password: <输入新设的密码newpassword>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

haiwei15

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值