Forgot your MySQL root password often we experience, why not? Because usually the MySQL root password is generally distinguished from our shell passwords, with the assumption that if the MySQL password we caught by someone who is not interested in the machine we still survived. Bugs in web applications is generally the main cause and if a cracker can take his MySQL root password and user passwords coincidence shell is equal to the MySQL root password, a cracker can finally do a full control on our FreeBSD machine. From the phenomena above, most admins always distinguish the shell with the root password mysql root password and it often causes you to forget the root password access to mysql mysql database must be done rarely.
Ok let's start step by step to reset the mysql root passowrd. The first time you have to do is login as root to your server and do it step by step below properly and correctly. If we're running mysql server then we should shut down first.
indofreebsd # / usr / local / etc / rc.d / mysql-stop server.sh
Then go to user mysql:
indofreebsd # su mysql
$ Id
uid = 1217 (mysql) gid = 1217 (mysql) groups = 1217 (mysql)
and run the command:
$ / Usr / local / bin / mysqld_safe - skip-grant-tables &
Run the mysql client:
$ Mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 1 to server version: 4.1.18
Type 'help;' or '\ h' for help. Type '\ c' to clear the buffer.
mysql>
then go to mysql database
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
Reset your mysql root password in a way
mysql> UPDATE user SET Password = PASSWORD ('sayaorangganteng')
-> WHERE Host = 'localhost' AND User = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Flush privileges
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Exit from mysql monitor
mysql> exit
Bye
Exit from user mysql and back to the root
$ Exit
indofreebsd #
Find the server mysql pid
indofreebsd # ps ax | grep mysql
P2 I 12 132 00:00:01 / bin / sh / usr / local / bin / mysqld_safe - skip-grant-tables
12 145 p2 S 12:00:36 / usr / local / libexec / mysqld
- Basedir = / usr / local - datadir = / var / db / mysql - pid-file = / var / db / mysql / ind
12 169 p2 R + 00:00:00 grep mysql
Kill the pid
indofreebsd # kill -9 12 132 12 145
Make sure the process was bener bener dead mysql
indofreebsd # ps ax | grep mysql
indofreebsd #
if not dead yet turn off it, idiot if you can't do this :P.
then run the mysql server as usual
indofreebsd # / usr / local / etc / rc.d / mysql start-server.sh
Starting mysql.
indofreebsd #
Test your new password
indofreebsd # mysql-p
Enter password: sayaorangganteng
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 3 to server version: 4.1.18
Type 'help;' or '\ h' for help. Type '\ c' to clear the buffer.
mysql>
you can smile now :) , you get the root password without having to re-install mysql mysql.
The last step do not forget to exit from the mysql monitor
mysql> exit
Bye
indofreebsd #
yours respectfully,
ogeb
Friday, March 18, 2011
Forgot your MySQL root password
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment