mysql安全模式重置密码
-
停掉MariaDB服务:
systemctl stop mariadb
sudo mysqld_safe --skip-grant-tables --skip-networking &
- 直接用root登录,无需密码:
mysql -u root
- 重设密码:
mysql> use mysql; mysql> update user set password=PASSWORD("
passw@rd
") where User='root';
mysql> flush privileges;
- 重启服务:
systemctl restart mariadb
- 用新密码登录了:
mysql -u root -ppassw@rd