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 stop
verify whether mysqld process stopped, if not you can go ahead to kill it:
$ ps aux | grep mysql
Kill 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-tables
Step 3. Reset root password:
$ mysql mysql> use mysql; mysql> update user set password=PASSWORD("newpassword") where user="root"; mysql> quit;
You can also set password of any user here.