twitter
    Find out what I'm doing, Follow Me :)

Recover password root di MySQL

Langkah - langkah merecovery password root di database MySQL :

  • Login sebagai user root pada Linux.
  • Mematikan servis mysqld :
  • # /etc/init.d/mysql stop
    Stopping MySQL database server: mysqld.

  • Menghidupan servis mysqld dalam keadaan safe mode (tidak ada grant pada table)
  • # mysqld_safe --skip-grant-tables &
    [1] 674
    # nohup: ignoring input and redirecting stderr to stdout
    Starting mysqld daemon with databases from /var/lib/mysql

  • Konnek ke mysql server menggunakan mysql client :
  • # mysql -u root
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 1
    Server version: 5.0.67 Source distribution

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

    mysql>

  • Rubah password user root pada databse mysql :
  • 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 User='root';
    Query OK, 2 rows affected (0.00 sec)
    Rows matched: 3 Changed: 2 Warnings: 0

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    mysql> quit
    Bye

  • Mematikan servis mysqld :
  • # /etc/init.d/mysqld stop
    STOPPING server from pid file /var/run/mysqld/mysqld.pid
    090310 09:55:29 mysqld ended

    Stopping MySQL: [ OK ]
    [1]+ Done mysqld_safe --skip-grant-tables

  • Menghidupan servis mysqld secara normal :
  • # /etc/init.d/mysqld start
    Starting MySQL: [ OK ]

    Test konek menggunakan mysql client tanpa option password :
    # mysql -u root
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    Test konek menggunakan mysql client menggunakan option password :
    # mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 3
    Server version: 5.0.67 Source distribution

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

    mysql>

    0 comments: