MySQL root password forgotten solution in Linux environment

Source: Internet
Author: User
Tags mysql login

one of the ways to recover MySQL passwords1. First verify that the server is in a secure state, that is, no one can connect to the MySQL database arbitrarily. Because the MySQL database is completely out of password-protected state during the reset of the root password of MySQL, other users can log in and modify the MySQL information arbitrarily. It is possible to implement the server's quasi-security state by enclosing MySQL's external ports and stopping Apache and all user processes. The safest state is to operate on the console of the server and unplug the network cable. 2. To modify MySQL login settings: # VI/etc/my.cnf in[mysqld]Add one sentence to the paragraph: Skip-Grant-tables Save and Exit VI. 3. Restart Mysqld #/etc/Init.d/mysqld Restart (service mysqld restart)4. Log in and modify the root password for MySQL MySQL>  UseMySQL ; MySQL> UPDATE User SETPassword=Password ('New-password')WHERE User = 'Root'; MySQL>FlushPrivileges; MySQL>quit5. Change MySQL login settings back to # VI/etc/MY.CNF would have just[mysqld]In the paragraph, add the Skip-Grant-Tables Delete Save and Exit VI. 6. Restart Mysqld #/etc/Init.d/mysqld Restart (service mysqld restart)7. Restoring the server's normal working state reverses the operation in step one. Restores the server's working status. MySQL Password recovery method Two If you forget the root password of MySQL, you can reset it in the following ways:1. Kill the MySQL process in the system; Killall-Term mysqld2start MySQL with the following command to start without checking permissions; Safe_mysqld--Skip-grant-tables &3. Then log in to MySQL using the root user with a blank password; MySQL-u root4. Modify the root user's password; MySQL> UpdateMysql.User SetPassword=PASSWORD ('New Password')where User='Root'; MySQL>FlushPrivileges; MySQL>quit restart MySQL, you can use the new password to log in to the MySQL password recovery method Three possible your system does not have SAFE_MYSQLD program (for example, I am using the Ubuntu operating system, APT-get installed MySQL), the following method can be restored1. Stop mysqld;/etc/Init.d/MySQL Stop (you may have other ways to stop mysqld running anyway)2start MySQL with the following command to start without checking permissions; Mysqld--Skip-grant-tables &3. Then log in to MySQL using the root user with a blank password; MySQL-u root4. Modify the root user's password; MySQL> UpdateMysql.User SetPassword=PASSWORD ('NewPassword')where User='Root'; MySQL>FlushPrivileges; MySQL>quit restart MySQL/etc/Init.d/MySQL restart can log in with the new password newpassword. 

MySQL root password forgotten solution in Linux environment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.