How to reset root user password in MySQL 5.7+

Was too busy and haven’t written anything for quite a while!

Anyway, here is how to reset the root user password in MySQL 5.7 and later in a nutshell!

service mysql stop
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
mysqld_safe --skip-grant-tables &
mysql

mysql> UPDATE mysql.user SET authentication_string=PASSWORD('new-password') WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;

mysqladmin -u root -p shutdown
service mysql start

That’s it, Enjoy!

Sources:

About SoCRaT

Systems Engineer, OSS & Linux Geek
This entry was posted in Linux, MySQL and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s