Reset root password on MySQL

Start MySQL server without user authentication and networking, this allows to connect without credentials from localhost only. Run using the same user account the MySQL daemon runs under to avoid permission problems (probably, sounds reasonable doesn’t it?)

sudo -u mysql_account mysqld_safe --skip-grant-tables --skip-networking &

Connect to MySQL with no credentials:

mysql

Reload authentication:

FLUSH PRIVILEGES;

Change root password:

MySQL 5.7.6 and later:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

MySQL 5.7.5 and earlier:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');

From here: http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

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