linux-mysql忘記密碼

1.修改mysqld.cnf配置文件

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

在[mysqld]中加入

skip-grant-tables

2.重啓mysql

service mysql restart

3.修改密碼

mysql -u root
use mysql;
update user set authentication_string=password('新密碼'),plugin='mysql_native_password' where user='root';
flush privileges;
exit

4.註釋掉mysqld.cnf配置文件添加的skip-grant-tables

5.重啓mysql

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章