mariadb忘记root密码

sudo systemctl stop mysql
sudo mysqld_safe --skip-grant-tables &
新开一个命令行窗口
mysql -u root
mysql> FLUSH PRIVILEGES;
mysql> use mysql;
mysql> update user set plugin="mysql_native_password" where User='root';
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password_here';
mysql> FLUSH PRIVILEGES;
mysql> quit;

sudo systemctl restart mysql


另一种修改密码命令
UPDATE mysql.user SET authentication_string=PASSWORD('YOUR-NEW-PASS'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';
posted @ 2020-12-27 11:11  mofy  阅读(165)  评论(0编辑  收藏  举报