Changing mysql root password when you have lost the original password.
sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
Now type the following command, you should not be prompted for a password when you enter this command
mysql -u root
use mysql;
Change the password for root user with:
update user set password=PASSWORD("mynewpassword") where User='root';The flush privileges;
flush privileges;Now exit out of mysql.
root@linux ~]# service mysqld stop 150404 20:55:28 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended Stopping mysqld: [ OK ] [1]+ Done sudo mysqld_safe --skip-grant-tables