ubuntu系统上MySQL8密码修改root

1.查询root用户authentication_string字段是否为空。

2.authentication_string字段是空,那么可以直接设置。

上述方法可能不生效,root用户无法登录MySQL可以用以下方案。

1.MySQL安装会有个默认的用户名和密码保存在/etc/msyql/debian.cf文件中

su root
cat /etc/mysql/debian.cnf

2.使用默认用户名密码登录进入MySQL数据

mysql -u debian-sys-maint -p

3.更新root用户的plugin模式为mysql_native_password

use mysql
update user set plugin='mysql_native_password' where user='root';

4.查看是否更新成功

select user,plugin from user;

5.设置root密码

alter user 'root'@'loacalhost' identified by '12345678';

6.刷新

flush privileges;

7.重启mysql

systemctl restart mysql

  • 8
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值