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
文章讲述了如何解决root用户authentication_string为空导致的MySQL登录问题,包括检查默认凭证、修改plugin模式、设置新密码并刷新权限,最后重启服务。
1386

被折叠的 条评论
为什么被折叠?



