Tuesday, November 16, 2010

Reset password root mysql

Mungkin anda sebagai seorang Admin pernah lupa dengan pasword root mysql? berikut ini adlah cara mereset Password root mysql:

1. stop mysql server dengan perintah
# /etc/init.d/mysqld stop

2. Jalan kan mysql tanpa password:
# mysqld_safe --skip-grant-tables &

3. Masuk ke mysql
# mysql -u root

4. Setup password untuk Mysql:
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

5. Stop mysql
# /etc/init.d/mysqld stop

6. jalankan mysql server kembali:
# /etc/init.d/mysql start

Sampai step ini password anda telah berhasil di ganti.

perintah lengkapnya adalah :

[root@server ~]# /etc/init.d/mysqld stop
Stopping MySQL: [ OK ]
[root@server ~]# mysqld_safe --skip-grant-tables &
[1] 15920
[root@server ~]# Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[15973]: started

[root@server ~]# mysql -u root

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 110
Server version: 5.0.91 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

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("passwordmysqlsaya") where User='root';
Query OK, 3 rows affected (0.06 sec)
Rows matched: 3 Changed: 3 Warnings: 0

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

mysql> quit
Bye
[root@server ~]# /etc/init.d/mysqld stop
STOPPING server from pid file /var/run/mysqld/mysqld.pid
Stopping MySQL: [ OK ]
[root@server ~]#
[root@server ~]# mysqld_safe[29913]: ended

[1]+ Done mysqld_safe --skip-grant-tables
[root@server ~]# /etc/init.d/mysqld start
Starting MySQL: [ OK ]
[root@server ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.0.91 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Selamat mencoba.

No comments:

Post a Comment