>How to reset MySQL root password ?

This page will help you to reset the root password of MYSQL database

Reset the Root Password

Blog Single

Default installation

/!\ This is for educational purposes only, and should not be used for unauthorized access, tampering or accessed illegally without owner permission.

Remember : if you have never assigned a root password for MySQL, the server does not require a password at all for connecting as root.
However, this is completely insecure !

I know the root password but need to change it

The SET PASSWORD syntax will help you :

											SET PASSWORD [FOR user] = password_option

												password_option: {
													PASSWORD('auth_string')
												  | OLD_PASSWORD('auth_string')
												  | 'hash_string'
												}
											
You will get more information at http://dev.mysql.com/doc/refman/5.0/en/set-password.html.

I don't know / I forgot the root password - Windows and Linux

All you need to know is here, for Windows and Linux :http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html.

Ok, Facebook site/software are all bullshit. But I need to steal a Facebook password !

As any other website or web services (Yahoo, Gmail...), it's possible to get credentials using conventional techniques :

  • Phishing : use of Fake Login Pages, also known as spoofed or phishing pages. These fake login pages resemble the original login pages of sites like Yahoo, Gmail, etc. The victim is fooled to believe the fake facebook page to be the real one and enter his/her password. But once the user attempts to login through these pages, his/her facebook login details are stolen away.
  • Keylogging : locally or remotely install a keylogger application on the victim's computer. It records the keystrokes into a log file and then you can use these logs to get required Facebook, GMail, etc password.
  • Primary email address hack / Reset : simply ask Facebook to send password reset email to the victim's primary email address - of course if this email account is already compromised : reset page.
  • Social engineering : method of retrieving password or answer of security question simply be quering with the victim. You have to be careful while using this as victim must not be aware of your intention. Just ask him cautiously using your logic.
  • Cookie Stealing / Session Hijacking : Google it. See for example FireSheep

I don't know / I forgot the root password - Others system

On any platform, you can reset the password using the mysql client :

  • Stop the MySQL server if necessary, then restart it with the --skip-grant-tables option. This enables anyone to connect without a password and with all privileges, and disables account-management statements such as SET PASSWORD. Because this is insecure, you might want to use --skip-grant-tables in conjunction with --skip-networking to prevent remote clients from connecting.
  • Connect to the MySQL server using the mysql client; no password is necessary because the server was started with --skip-grant-tables:
    shell> mysql
    In the mysql client, tell the server to reload the grant tables so that account-management statements work:
    mysql> FLUSH PRIVILEGES;
    Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use. To change the password for a root account with a different host name part, modify the instructions to use that host name.
    mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
  • You should now be able to connect to the MySQL server as root using the new password. Stop the server and restart it normally (without the --skip-grant-tables and --skip-networking options).
Share this Post: