1. Shutdown the MySQL Server –
a. Use windows services to shut down: Start > run > services.msc > MySQL > right click and select STOP
b. Using mysqladmin by running following command in command prompt:
mysqladmin -u root shutdown (make sure to provide the correct path for mysqladmin if it has not been added in windows path)
2. Start the MySQL Server in safe mode (anonymous login):
C:\>start mysqld-nt --skip-grant-tables (A black screen will flicker and here you go)
In UNIX environment u has to use below command:
mysqld_safe --skip-grant-tables
3. Now you open the command line and try to connect to the root user with empty password by running below command:
C:\>Mysql -uroot
4. when you logged in u will get a prompt as
mysql>
5. Now select the MySQL database:
use mysql;
6. Update the root password by running this command:
mysql> update user set Password=PASSWORD('<new-password>') WHERE User='root';
7. Shutdown the MySQL Server: (it is very important to stop the server at this stage since it is running in anonymous mode):
mysqladmin -u root shutdown
8. Now start server again and can log in with new password.
a. Use windows services to shut down: Start > run > services.msc > MySQL > right click and select STOP
b. Using mysqladmin by running following command in command prompt:
mysqladmin -u root shutdown (make sure to provide the correct path for mysqladmin if it has not been added in windows path)
2. Start the MySQL Server in safe mode (anonymous login):
C:\>start mysqld-nt --skip-grant-tables (A black screen will flicker and here you go)
In UNIX environment u has to use below command:
mysqld_safe --skip-grant-tables
3. Now you open the command line and try to connect to the root user with empty password by running below command:
C:\>Mysql -uroot
4. when you logged in u will get a prompt as
mysql>
5. Now select the MySQL database:
use mysql;
6. Update the root password by running this command:
mysql> update user set Password=PASSWORD('<new-password>') WHERE User='root';
7. Shutdown the MySQL Server: (it is very important to stop the server at this stage since it is running in anonymous mode):
mysqladmin -u root shutdown
8. Now start server again and can log in with new password.