MySQL重置默认根登录

问题描述 投票:-1回答:2

我以某种方式改变了我对本地MySQL的root登录。具体来说,我浏览了this Spring指南,其中包括创建一个MySQL用户springuser。不确定我是否做错了,但现在当我尝试以root用户身份登录MySQL(root,密码)时,它失败了:

enter image description here

...但是以spring用户身份登录(spring用户,密码):

enter image description here

我能以某种方式更改/重置我的root登录凭据,而我能够以root用户身份登录吗?

我已经尝试过没有运气的this(可以预见,因为我认为springuser没有root访问权限):

enter image description here

我也试过this,但得到了这个错误:

enter image description here

所以我创建了dir(... \ data)并运行了init命令(在关闭MySQL之后)它看起来像是有效的(没有错误),但是当我再次尝试登录时,我得到Access Denied:

enter image description here

mysql
2个回答
0
投票

尝试相当于Windows的Windows:

停止mysqld—skip-grant-tables —skip-networking重新启动它连接到它(如果你需要提供一个用户,则不确定)

use mysql;
update user set authentication_string=password('newpassword') where user='root';
flush privileges;
\q

停止mysqld重新启动mysqld没有上述标志


0
投票

只有对我有用的是重新安装MySQL。

© www.soinside.com 2019 - 2024. All rights reserved.