删除DATA文件夹

rm -rf /var/lib/mysql

重新初始化并启动MYSQL

mysqld --initialize --console --lower-case-table-names=1

vim /etc/my.cnf.d/mysql-server.cnf
--增加
skip-grant-tables
lower-case-table-names=1

chown -R mysql:mysql /var/lib/mysql/
systemctl start mysqld
systemctl status mysqld

重新初始化登录帐户

vim /etc/my.cnf.d/mysql-server.cnf
--增加
skip-grant-tables
lower-case-table-names=1
--退出后重启
systemctl stop mysqld
systemctl start mysqld
--开始重置密码
mysql -uroot -p --输入任意密码
--必须先执行 flush privileges,否则会报The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
flush privileges;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'tw369.com';
UPDATE USER SET host ="%" where user = "root"; 
flush privileges;
exit

启动服务

删除配置文件的 skip-grant-tables

systemctl restart mysqld

相关文章:

  • 2022-12-23
  • 2021-07-19
  • 2021-11-09
  • 2021-11-09
  • 2022-01-11
  • 2021-12-17
  • 2022-02-05
猜你喜欢
  • 2021-11-09
  • 2022-12-23
  • 2021-09-25
  • 2022-12-23
  • 2021-12-23
  • 2021-10-29
相关资源
相似解决方案