How to reset MySQL root password
One day you forgot your root password for your MySQL database server and blaming yourself for not written it somewhere for easy access.
Ok, do it no more! here's my short version (of official instruction) for advance user who does not need too much of instruction details
On Windows
- As admin, Stop the MySQL server, make sure it's completely stop
- Create a text file eg.
C:mysql-init.txtand past the following statement inUPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root'; FLUSH PRIVILEGES;
- Open up your Windows Command Prompt
- Run this command
C:mysqlbinmysqld-nt --init-file=C:mysql-init.txt
Change path if your sever install on somewhere else.
For wizard installation of mysql, you might have to do this"C:Program FilesMySQLMySQL Server 5.0binmysqld-nt.exe" --defaults-file="C:Program FilesMySQLMySQL Server 5.0my.ini" --init-file=C:mysql-init.tx
- Now delete
C:mysql-init.txtthen restart MySQL server again
On Linux or Unix
- Stop MySQL server as follow
Find .pid file in /var/lib/mysql/, /var/run/mysqld/ and /usr/local/mysql/data/ - Now run
$ kill `cat /mysql-data-directory/host_name.pid`
- Create a text file eg.
/home/yourid/mysql-initand past the following statement inUPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root'; FLUSH PRIVILEGES;
- Start mysql server with the following options
mysqld_safe --init-file=/home/me/mysql-init &
- Delete mysql-init file then finished
Alternative but less secure
- Stop
mysqldand restart it with the--skip-grant-tablesoption. - Connect to the mysqld server with this command
$ mysql
- Now run the following statement
UPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root'; FLUSH PRIVILEGES;
- Finished



Eclipse IDE for Java EE Developers
Eclipse Classic

Amazon

