1> First, stop the database
sudo /etc/init.d/mysql stop
2> Start mysqld_safe [which starts the mysql server in safe option] LIke to restart server when some error occured. For more details click here.
Similarily we are using mysqld_safe for resetting lost/forgot password.
sudo /etc/init.d/mysql stop
2> Start mysqld_safe [which starts the mysql server in safe option] LIke to restart server when some error occured. For more details click here.
Similarily we are using mysqld_safe for resetting lost/forgot password.
/usr/bin/mysqld_safe --skip-grant-tables &
You have to run above using root (sudo -i)
3> It shows mysql daemon started with databases in /var/lib/mysql
Since server is running with --skip-grant-tables flag, means you can access the database without password
Now write the command :
mysql --user=root mysql
Enter your root password
4> Now since we have to update our password in User table. Therefore
We provide command :
Update user set Password=PASSWORD("Your New Password") Where User='root';5> Flush Privileges :
Means clear and reload the priviledges.
So command will be
flush privileges; More about flush option click here
6> Exit Mysql
7>Now You have to stop the Daemon Mysql server
It is a two step process :
Firstly bring the Background process to Foreground
Command used for this is :
fg
Kill the Foreground process
Ctrl + c [But sometimes Ctrl +z]
8>Now start the mysql
sudo /etc/init.d/mysql start
9>Now go to mysql
mysql --user=root --pass=newpassword