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 mysqld

Step 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 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.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes