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
2 Responses to Resetting MySQL Root Password on CentOS
  1. Dont work for me 🙁

    • Sorry for the late reply, can you share any details? I’ve also used this method on Raspberry Pi’s (Raspbian) and it works, maybe I can help you if you give me any shell outputs.


[top]

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: