In Open Source community Mysql is the one of the most popular RDBMS engine , While using Mysql sometimes System Administrators or Integrator might forget the password of mysql’s root user and is required to reset to reset the password for root user.
Below steps will help you to reset mysql’s root user password
Step 1 : Stop mysql service
# /etc/init.d/mysqld stop |
Step 2 : Start MySQL server service without password
# mysqld_safe –skip-grant-tables & |
We need to run mysqld_safe service in background to reset the root password. You will see output something like below
[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started
Step 3 : Connect to mysql server using mysql client
# mysql -uroot -p |
You will see output something as below
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>
Step 4 : Assign new password to root user
mysql> use mysql; mysql> update user set password=PASSWORD(“NEW-ROOT-PASSWORD”) where User=’root’; mysql> flush privileges; mysql> quit |
Where NEW-ROOT-PASSWORD will be the the new password for mysql’s root user
Step 5 : Restart mysql service
Restart of mysql service is required to stop failsafe mysql daemon and start default daemon for mysql
# /etc/init.d/mysqld stop
#/etc/init.d/mysqld start |