* Stop MySQL service
# /etc/init.d/mysqld stop
Output:
Stopping MySQL database server: mysqld.
* Now, start MySQL server without password using the below command
# mysqld_safe –skip-grant-tables &
Output:
[1] 5988 Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[6025]: started
* Connect to MySQL server using the following command.
# mysql -u root
Output:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
* Then you will enter into the MySQL prompt.
mysql>
* In order to reset the root password, you can run the following mysql commands in the mysql prompt.
mysql> use mysql;
mysql> update user set password=”new root password’ where user=’root’;
mysql> flush privileges;
mysql> quit;
* Now, stop MySQL server
# /etc/init.d/mysqld stop
Output:
Stopping MySQL database server: mysqld STOPPING server from pid file /var/run/mysqld/mysqld.pid mysqld_safe[6186]: ended [1]+ Done
*Start MySQL server and test it
# /etc/init.d/mysql start
# mysql -u root -p