Have you ever seen the dreaded MySQL Error number 1045 Access denied for user ‘root’@’localhost’ (using password: YES)?
Don’t worry, this is an easy to recover from situation. Just follow these basic steps to reset the root user password.
Stop the MySQL server process.
Start the MySQL server process with the –skip-grant-tables option. This option causes the server to start without using the privilege system at all, which gives anyone with access to the server unrestricted access to all databases. BEWARE! Anyone can access your server, so make sure off the Internet, and that you perform the following steps as quickly as possible.
Start the MySQL console client with the -u root option. Mysql -u root
SELECT * FROM mysql.user;
UPDATE mysql.user SET Password=PASSWORD(‘[password]’) WHERE User='[username]’; Replace [username] with root to change root. You can also change any other user as well.
Stop the MySQL process
Start the MySQL Process normally (i.e. without the –skip-grant-tables option).
Some folks have reported that issuing a Flush Privileges command will prevent your having to perform the final Stop/Start of the MySQL server. However, this has not always worked for me, and I think to be safe, it is wise to recycle the server.
- Bell X-2 StarBuster Replica
- Bell P-39N Airacobra – Little Sir Echo – Small Fry