由于一时疏忽数据库被黑了,root密码被改掉,找回数据需要支付$300,卧槽无情,没有办法重新更改root,找回数据库备份数据,我的数据库安装在ubuntu系统所以mysqld.cnf文件路径和centos不一致,方法都是大同小异

1>编辑mysqld.cnf文件

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

2>在文件中的skip-external-locking一行的下面添加一行

skip-grant-tables

mysqld.cnf.png

3>重启MySQL服务

sudo service mysql restart

4>终端输入mysql进入MySQL,输入USE mysql切换至mysql数据库

mysql
USE mysql

5>把root用户的密码修改为000000

UPDATE mysql.user SET authentication_string=password('000000') WHERE User='root' AND Host ='localhost';

6>修改字段plugin

UPDATE user SET plugin="mysql_native_password";

7>更新

flush privileges;
Last modification:September 4th, 2020 at 05:19 pm
如果觉得我的文章对你有用,请随意赞赏