dwdraju
2/8/2017 - 4:48 AM

mysql reset password

mysql reset password

Set up root password for the first time
$ mysqladmin -u root password newpass

Change (or update) a root password
$mysqladmin -u root -p oldpassword newpass

Change a normal user password
$mysqladmin -u user-name -p oldpassword newpass

Change pass for user
mysql> update user set password=PASSWORD("newpass") where User='ENTER-USER-NAME-HERE';
mysql> flush privileges;
mysql> quit

Recover
# /etc/init.d/mysql stop

 Start the MySQL server w/o password:
# mysqld_safe --skip-grant-tables &

mysql -u root

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop

# /etc/init.d/mysql start
# mysql -u root -p