MySQL forgot root password solution

Source: Internet
Author: User
Tags mysql login

in the actual operation to forget the root password of MySQL is a very headache, do not hurry the following article is to introduce the root password of the MySQL forget the solution, we can do the following steps to reset, the following is the detailed description of the article.  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.  First, LINUX1, modify the MySQL login settings:# vim/etc/my.cnfadd a sentence to the paragraph in [mysqld]: Skip-grant-tablesFor example:[MySQL]Datadir=/var/lib/mysqlSocket=/var/lib/mysql/mysql.sockSkip-name-resolveSkip-grant-tablesSave and exit Vim 2. Restart MySQL#/etc/init.d/mysql Restart (specific restart modes vary)stopping MySQL: [OK]starting MySQL: [OK] 3. Log in and modify MySQL password#/usr/bin/mysqlWelcome to the MySQL Monitor. Commands End With; or \g.Your MySQL Connection ID is 2973379Server version:5.5.30-log Source distribution Copyright (c) and/or, Oracle, its affiliates. All rights reserved. Oracle is a registered trademark of the Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement. mysql> use MySQL;mysql> Update user set Password=password (' New-password ') where user= ' root ';mysql> flush Privileges;Mysql> quit 4. Change the MySQL login settings back# vim/etc/my.cnfDelete the skip-grant-tables you just added in the paragraph [mysqld]Save exit Vim 5. Restart MySQL#/etc/init.d/mysql Restartstopping MySQL: [OK]starting MySQL: [OK]  Second, WINDOWS 1> Login System as System administrator.  2> Open cmd-–net start to see if MySQL is started. Stop the net stop MySQL when you start 3> My MySQL is installed under D:\usr\local\MySQL4\bin.  4> Skip permission check to start MySQL. D:\usr\local\mysql4\bin\mysqld-nt–skip-grant-tables 5> re-open cmd. Enter under D:\usr\local\MySQL4\bin: d:\usr\local\MySQL4\bin\MySQLadmin-uroot flush-privileges Password "NewPassword" d:\usr\local\MySQL4\bin\MySQLadmin-u root-p Shutdown This sentence prompts you to re-lose the password.  6> in cmd net start MySQL 7> 's done.  attached: MySQL4.1 or above a workaround for a password error problem 1 # SET PASSWORD for ' some_user ' @ ' some_host ' = Old_password (' newpwd '); 2 # FLUSH privileges; 3,mysql Database Repair myisamchk-r-Q d:\mysql\data\latin1\*R represents the repair Q stands for fast d:\mysql\data\latin1\* Database * represents all the files inside. the above related content is the MySQL reset root password introduction, hope you can gain.

MySQL forgot root password solution

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.