# service mysqld stop
找到MySQL的my.cnf配置文件,在/etc/my.cnf (有些版本是/etc/mysql/my.cnf)在里面增加下面一段信息:

[mysqld]

skip-grant-tables

然后启动MySQL,进入MySQL后,修改root密码

mysql> use mysql;
mysql> update mysql.user set authentication_string=password('Kd8wertrtel023') where user='root';
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit

在my.cnf文件中,把刚才加入的那一行“skip-grant-tables”注释或删除掉。 然后重启MySQL服务后需要执行命令set password=password('newpassword');后,问题搞定。

# service mysqld start
# mysql -u root -p
mysql> use mysql;
mysql> set password=password('Kd83456dl023');

相关文章:

  • 2021-09-16
  • 2021-09-27
  • 2021-10-10
  • 2021-07-06
  • 2021-12-04
猜你喜欢
  • 2021-04-01
  • 2021-05-22
  • 2021-12-16
  • 2022-01-16
  • 2021-04-16
  • 2021-12-13
  • 2021-12-04
  • 2021-08-16
相关资源
相似解决方案