Recover or Reset root password of MySQL and PostgreSQL Servers
Forgot password of MySQL/PostgreSQL? Here is quick howto to recover/reset the password of root user in both Servers:
MySQL:
Step 1. Stop mysql server or Kill it:
# service mysqld stopverify whether mysqld process stopped, if not you can go ahead to kill it:
# ps aux | grep mysqlKill all processes shows by above command.
OR
# killall mysqldStep 2. Start mysqld process manually without using grant table (to skip requirement of user/password):
# /bin/sh /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid --skip-grant-tablesStep 3. Reset root password:
# mysql (mysql prompt)# use mysql; (mysql prompt)# update user set password=PASSWORD("newpassword") where user="root"; (mysql prompt)# quit;
You can also set password of any user here.