Hello, If you maybe forget your root MySQL server password, do not panic it can be flushed and then reset very easily
- Stop the current MySQL server instance, then restart it with an option to not ask for a password.
1 2
sudo /etc/init.d/mysqld stop sudo mysqld_safe --skip-grant-tables &
- Reconnect to the MySQL server with the MySQL root account.
1
mysql -u root
- Use the following commands to reset root’s password. Replace
password
with a strong password.1 2 3 4
use mysql; update user SET PASSWORD=PASSWORD("yorsnewpassword") WHERE USER='root'; flush privileges; exit
- Then restart MySQL.
1
sudo service mysqld restart
You’ll now be able to log in again using mysql -u root -p
.
proved to be very easy? I hope this helps 😀