Reset mysql root password from command line
Stop mysql server
[root@server ~]# service mysqld stop
Stopping mysqld: [ OK ]
OR
[root@server ~]# /etc/init.d/mysqld stop
Stopping mysqld: [ OK ]
Start mysql configuration, Execute the command as mysql safemode:
[root@server ~]# mysqld_safe --skip-grant-tables &
Replace old password with the new one from mysql command prompt.
mysql> update user set password=PASSWORD("newpassword") where User='root'; FLUSH PRIVILEGES; exit;
Restart mysql server.
[root@server ~]# service mysqld restart
Access mysql by using new password
[root@server ~]# mysql -u root -p
Enter password:
Leave a Comment