[MySQL]Reset the root password

For users of the powerful database MySQL, access, as well as right to modify the admin (root) password is important, because both are required when installing and in situations when the master password is lost. The user must be connected to the root password to modify it but for reinitialising the password, this process can be skipped. Resetting the password is possible after connection to the MySQL database with the help of specific commands. In case the password is lost, then it is also possible to get access to the MySQL server through a bypass of the authentication process. To reset the password under the latter condition, the server must be restarted to continue the process.

[MySQL]Reset the root password




It's important that you are able to access and modify the admin (root) password of MYSQL, either when installing MySQL for the first time or in situations where the master password is lost.

The root password is lost


To modify the existing root password, you must firstly be connected to it. If you know the root password and just want to reinitialize it, you can skip this part. If you don't have the root password then follow the steps below:
  • Stop the MySQL server
    • #/etc/init.d/mysql stop
  • Restart MySQL, disabling network communication and skipping the authentication procedure
    • #mysqld --skip-grant-tables --skip-networking &

Resetting the password

  • Get connected to the MySQL system database:
    • # mysql mysql -u root
  • Type in the following command and reset your password:
    • UPDATE user SET password=PASSWORD('newpassword') WHERE user="root";
  • If you didn't go through the first step, to validate the changes simply type:
    • FLUSH PRIVILEGES;
  • If you started MySQL manually (bypassing the authentication process), the server must be restarted:
    • #/etc/init.d/mysql restart


Warning: Changing your password can cause connection problems between phpmyadmin and mysql.


Original FAQ by Jeff on CCM.
Published by jak58 - Last update on February 14, 2012 02:26 PM by Paul Berentzen
This document entitled « [MySQL]Reset the root password » from Kioskea.net (en.kioskea.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the licence, as this note appears clearly.
Suggestions
  •  [MySQL]Reset the root password
  •  PhpMyAdmin - Access denied for user root@localhost » Tips : In the PHP programming language, there is an open source tool called PhpMyAdmin that handles the administration of MySQL. Access can be denied when access to MySQL is attempted through theroot user. Root requires insertion of a password and once that...
  •  Change Mac admin password without the disk (Solved) » Best answer: You can try this: Creating a new Admin on Mac Os X: Here's how to reset your OS X password without an OS X CD. the Working solution for me was to create a new admin you can create new admin like this by deleting a specific file. You need to e
  •  Reinitializing the root password of MySQL » Tips : Reinitializing the root password of MySQL The root password is lost! Reinitializing the password: It's important that you are able to access and modify the admin (root) password of MYSQL, either when installing MySQL for the first time...
  •  Changing password via a script » Tips : To change a password in Linux through a Bash script, he two scripts that are most important are 'Create Users' and 'Change Passwords Shell' scripts, for the system admin which regularly uses the mail servers, as there might be multiple...
  •  WD My Book reset password (Solved) » Best answer: Hi, Download wdsmartwareupdate here : http://www.wdc.com/wdproducts/wdsmartwareupdate/ Download instructions : 1- Locate you WD disk entry, click on Windows or Mac according to your operating system. 2 - Click on Download now link at the bott
MySQL real time monitoring
DUPLICATE ENTRY '127' FOR KEY 1