How to Reset user root on Mysql

Have u ever forget ur root password on ur server ..
Well i have often forget about it..

So i write it here to help me when i forget my password again

first of all .. u should connect to ur server using ssh or telnet
and log in to ur root account

  1. After u log in as root u should stop mysql server before we can proceed type this line
    “/etc/init.d/mysqld stop”
  2. and then u should restart mysql with disabling network comunication and skipping the authentication procedure
    ” /usr/bin/mysqld_safe –skip-grant-tables  “
  3. And try to open new session or duplicate session and try to connect to mysql and type this line
    ” /usr/bin/mysql
    u will see
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 15 to server version: 5.0.22

    Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

    mysql> use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
    mysql> UPDATE user SET Password=PASSWORD(‘password’)
    -> WHERE Host=’localhost’ AND User=’root’;
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0

  4. Don’t forget to flush all the privilages using
    FLUSH PRIVILEGES;
    mysql> exit
  5. Restart mysql using ” /etc/init.d/mysqld restart”

there u go ..
hope it can help me again sometimes

  1. Update your trick with this working one, http://blog.dextone.co.cc/mysql-root-passwod-reset

  1. November 30th, 2010

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: