Tag: MySQL
Exploits of a Mom:
Teacher: “Hi, this is your son’s school. We’re having some computer trouble.”
Mom: “Oh, dear – Did he break something?”
Teacher: “In a way… Did you really name your son Robert’); DROP TABLE Students;–?”
Mom: “Oh, yes. Little Bobby Tables we call him.”
Teacher: “Well, we’ve lost this year’s student records. I hope you’re happy.”
Mom: “And I hope you’ve learned to sanitize your database inputs.”
[ad name=”Adsense – text only”]
Source: xkcd.com/327
How To Recover Your MySQL root Password
I just needed to recover a lost MySQL root password on a clients server recently and thought I’d share the method I used.
[ad name=”Adsense – text only”]
Actually it’s not a method for recovering but you can change the forgotten password to a new one.
All you need is to follow this 6 easy steps:
Step 1: Stop the mysql service
Expected Output:
Step 2: Start the MySQL server without password
Expected Output:
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started
Step 3: Connect to your MySQL server using the MySQL client
Expected Output:
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Step 4: Setup a new MySQL password for the root user
mysql> update user set password=PASSWORD("YOUR-NEW-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit;
Expected Output:
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
Query OK, 0 rows affected (0.00 sec)
Bye
Step 5: Stop the MySQL Server
Expected Output:
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended
[1]+ Done mysqld_safe --skip-grant-tables
Step 6: Start the MySQL server and test it
# mysql -u root -p
Expected Output:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is xx
Server version: x.x.xx XXXXX MySQL RPM
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Now you should be all done!
I hope this helps you as much as it did for me.