How to reset MySQL root password

Categories: Database; Tagged with: ; @ May 1st, 2016 15:27

I lost root’s password, again.

stop MySQL

we need to stop mysql and start it in safe mode.  I tried many ways to kill mysql, but only this works for my Ubuntu 14.04:

[email protected]:/usr/bin# initctl --system stop mysql

start MySQL in safe mode, set new password for root

sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set password=PASSWORD("new_password") where User='root';
flush privileges;
quit
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

you may try to login using the new password now:

mysql -u root -p

store/update MySQL password in ~/.my.cnf

if you’re using a password file, remember to update it.

[client]
user=root 
password=new_password

useful links
http://stackoverflow.com/questions/18733944/ubuntu-cant-stop-mysqld
https://www.digitalocean.com/community/questions/setup-mysql-on-ubuntu-droplet-getting-error-error-1045-28000-access-denied-for-user-root-localhost-using-password-yes

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.