Lost mysql admin (root user) password. How do I reset a lost MySQL admin (root) password under UNIX or Linux or BSD operating systems?
Type the following commands. First, stop current MySQL database server:
Code:
/etc/init.d/mysql stop
OR
Code:
/etc/init.d/mysqld stop
Code:
/usr/local/etc/rc.d/mysql-server stop
Now, start mysql server without password so that you can restart the password:
Code:
mysqld_safe --skip-grant-tables &
Login without a password, enter:
Code:
mysql -u root
Finally, setup a new MySQL root user password, enter:
Code:
USE mysql; UPDATE user SET password=PASSWORD("NEW-ROOT-PASSWORD") WHERE User='root'; FLUSH privileges; quit
Replace NEW-ROOT-PASSWORD with actual password you want to use. Restart running mysql server:
Code:
/etc/init.d/mysql restart
Test it:
Code:
mysql -u root -p
Comment