It is not uncommon for you to need the MySQL root password of a server, especially when you’re dealing with hundreds of different servers. Here’s the quickest way to reset it. (Don’t forget that you need to login to your server as root in order to achieve this)

1) Start MySQL in safe mode.

2) Reset the root password.

3) Flush privileges.

4) Create a my.cnf file so that you can automatically log-in next time.

# service mysqld stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
> update mysql.user set password=PASSWORD("newpass") where User='root';
> flush privileges;
> exit;
# { echo "[client]"; echo "user=root"; echo "password=newpass"; } >> /root/.my.conf
# service mysqld restart

About The Author


This site uses Akismet to reduce spam. Learn how your comment data is processed.