Database and Indexing » MySQL
How do I reset (root) password for MySQL?
Alternative question: I forgot MySQL root password. How do I reset it?
MySQL database daemon (mysqld-nt.exe on Windows, mysqld on Linux and *nix) by default allows connection only after validating it against the users in the 'user' table in the 'mysql' database - what is referred to as the grant table.
You can turn this off by starting the server using --skip-grant-table option.
So, the steps would be:
- Stop MySQL server / daemon, if running.
- Start the daemon as
mysqld --skip-grant-table (On *nix / Linux et al)
mysqld-nt.exe --skip-grant-table (On Windows)
- Connect using the client and change the password
$mysql -u root (Don't specify any password, it won't be verified anyway)
mysql> use mysql;
mysql> UPDATE user SET Password='Password' WHERE User='root';
- Update privileges
mysql> FLUSH PRIVILEGES;
There's another way out... a slightly more cumbersome. That uses the MySQL feature that when it starts, it can execute a set of SQL statements.
That's in another FAQ :)
Last update: 2009-01-25 04:52
Author: Edujini Labs Pvt Ltd
Revision: 1.1
Print this record
Send to a friend
Show this as PDF file
Export as XML-File
You cannot comment on this entry