I installed LAMP on Ubuntu 12.04 LTS (Precise Pangolin) and then set root password on phpMyAdmin. I forgot the password and now I am unable to login. When I try to chan
I am seeing all these answers, but none offer the option to reset the password and no accepted answer. The actual question being he forgot his password, so he needs to reset, not see if it's running or not (installed or not) as most of these answers imply.
Follow these steps (can be helpful if you really forget your password and you can try it anytime, even if you're not in the situation at the moment):
Stop mysql
sudo /etc/init.d/mysql stop
Or for other distribution versions:
sudo /etc/init.d/mysqld stop
Start MySQL in safe mode
sudo mysqld_safe --skip-grant-tables &
Log into MySQL using root
mysql -uroot
Select the MySQL database to use
use mysql;
Reset the password
-- MySQL version < 5.7
update user set password=PASSWORD("mynewpassword") where User='root';
-- MySQL 5.7, mysql.user table "password" field -> "authentication_string"
update user set authentication_string=password('mynewpassword') where user='root';
Flush the privileges
flush privileges;
Restart the server
quit
Stop and start the server again
Ubuntu and Debian:
sudo /etc/init.d/mysql stop
...
sudo /etc/init.d/mysql start
On CentOS, Fedora, and RHEL:
sudo /etc/init.d/mysqld stop
...
sudo /etc/init.d/mysqld start
Login with a new password
mysql -u root -p
Type the new password and enjoy your server again like nothing happened
This was taken from Reset a MySQL root password.