Process
suggest change- Stop the MySQL (mysqld) server/daemon process.
- Start the server with
--skip-grant-tablesso it will not ask for a password:mysqld_safe --skip-grant-tables &. On MySQL 8.0 this also turns on--skip-networkingunless you disable that. - Connect as root:
mysql -u root - Reload the grant tables, then change the password.
FLUSH PRIVILEGESis required beforeALTER USERwhile the grant tables are skipped:
- (5.7.6 and newer):
FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-password'; - (5.7.5 and older, or MariaDB):
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new-password'); FLUSH PRIVILEGES;
PASSWORD() was removed in MySQL 8.0.
- Restart the MySQL server.
Note: this will work only if you are physically on the same server.
Online Doc: http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents