Follow these steps (can be helpful if you really forget your password and you can try it anytime, even if you're not in the situation at the moment): Stop mysql
sudo /etc/init.d/mysql stopor for other distro versions
sudo /etc/init.d/mysqld stopStart MySQL in safe mode
sudo mysqld_safe --skip-grant-tables &Log into MySQL using root
mysql -urootSelect the MySQL database to use
use mysql;Reset the password
update user set password=PASSWORD("mynewpassword") where User='root';Flush the privileges
flush privileges;Restart the server
quitStop and start the server again
ubuntu and debian
sudo /etc/init.d/mysql stop ... sudo /etc/init.d/mysql startOn CentOS and Fedora and RHEL
sudo /etc/init.d/mysqld stop ... sudo /etc/init.d/mysqld startLogin with new password
mysql -u root -pType new password and enjoy your server again like nothing happened
No comments:
Post a Comment