Fedora 重置 MySQL 密码

sudo mysqld --skip-grant-tables --user=root


mysql -uroot

flush-privileges;
或
FLUSH PRIVILEGES;

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
或
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');

flush-privileges;
或
FLUSH PRIVILEGES;

exit

sudo ps aux | grep -i "mysql"
sudo kill -9 9096

启动MySQL:
sudo systemctl start mysqld

若失败,检查日志:
sudo vi /var/log/mysqld.log
如果是Could not open unix socket lock file /var/lib/mysql/mysql.sock.lock
则:
sudo rm /var/lib/mysql/mysql.sock
sudo rm /var/lib/mysql/mysql.sock.lock

启动后修改密码,如果出现报错:Your password does not satisfy the current policy requirements
则执行:
mysql> set global validate_password_policy=0;