Reset Root password (MySQL)
If the root password for a MySQL server is lost, unknown or cannot be recovered it can be reset so long as you have root (Linux) or Local/Domain Admin (Windows) access on the MySQL server.
Procedure
- Locate your
my.conffile - the MySQL configuration file. On Linux it is normally/etc/mysql/my.cnfand it can be located through typinglocate my.cnfdepnding on what distro you have. - Stop the MySQL server:
/etc/init.d/mysql stop -
Edit the
my.cnffile and place the following line after the [mysqld] section: skip-grant-tables - Start the MySQL server:
/etc/init.d/mysql start - Now you can connect without a password; all grant commands will not
work though. Type the following:
$ mysql -u root
mysql> use mysql;
mysql> update mysql.user set Password=password('newpassword') where User='root';\ - Stop the MySQL server:
/etc/init.d/mysql stop - Remove or comment-out the
skip-grant-tablesline. - Start the MySQL server:
/etc/init.d/mysql start