How to implement Mysql forgot password recovery password _mysql

Source: Internet
Author: User
Tags flush mssql

First, server environment

1, the System windows2003 Chinese Enterprise Edition SP2

2, MySQL 5.1.55

3, PHP 5.2.17

4, IIS 6.0

Ii. the process of cracking

1. Stop MySQL service (as Administrator, run under cmd command line) Use the following command:

net stop MySQL

2. Use the command to start the MySQL database, the following command

Mysqld--skip-grant-tables or Mysqld-nt--skip-grant-tables

3. Open a new CMD window, do the following command operation

1, Mysql-uroot
2, update mysql.user set Password=password (' root ') where user= ' your password ';

As shown in figure:

4, open Task Manager, stop the MYSQL,MYSQLD process, use net start MySQL to start the mysqld service, you can use the root root password to enter the database (this step can be omitted to restart the machine)

mysql5.1 admin password crackedTo this end.
1. Send Kill command to MYSQLD server to turn off MYSQLD server (not kill-9), and the file that holds the process ID is usually in the directory where the MySQL database resides.
Killall-term mysqld
You must be a UNIX root user or an equivalent user on the server you are running to perform this operation.
2. Use the '--skip-grant-tables ' parameter to start the mysqld. (Linux under/usr/bin/safe_mysqld--skip-grant-tables, Windows C:\mysql\bin\mysqld--skip-grant-tables)

3. Then login to mysqld Server without a password,
>use MySQL
>update User Set Password=password ("New_pass") where user= "root";
>flush privileges;
。 You can also do this: ' mysqladmin-h hostname-u user password ' new password '.

4. Load permission table: ' mysqladmin-h hostname flush-privileges ', or use SQL command ' flush privileges '.
5.killall-term mysqld
6. Login with new password

Fix It: My actual operation under Windows is as follows
1. Close the running MySQL.
2. Open the DOS window and go to the Mysql\bin directory.
3. Enter Mysqld-nt--skip-grant-tables carriage return. If you don't get a hint, that's it.
4.Open a DOS window again(Because the DOS window is already unable to move), go to the Mysql\bin directory.
5. Enter MySQL return, if successful, will appear MySQL prompt >
6. Connection rights database >use MySQL; (> is the original prompt, don't forget the last semicolon)
6. Change Password:> update user set Password=password ("123456") where user= "root"; (Don't forget the last semicolon)
7. Refresh permissions (necessary steps) >flush privileges;
8. Exit > \q
9. Logout system, re-enter, open MySQL, use user name root and just set the new password 123456 login.

It is said that you can use the method of directly modifying the user table file:
Close Mysql,windows Open Mysql\data\mysql, there are three files User.frm,user. Myd,user. Myi find a password to know the MySQL, replace the corresponding three files, if the user table structure has not changed, generally no one to change, replace user. MyD is OK.
You can also edit the user directly. MyD, find a hexadecimal editor, UltraEdit has this function. Turn off MySQL and open user. MyD. Change the eight characters after user name root to 565491d704013245, and the new password is 123456. Or they correspond to the hexadecimal digits (two digits to the left, a character), to 00 02 02 02 02 02 02 02, which is the blank password, and the right side of the editor is an asterisk *, which looks like a decimal point. Re-open MySQL and enter root and your new password.
some things to go into the MSSQL today, because it was a long time ago, so forget the sa password, although the use of Windows authentication can be entered, but if the use of PHP to connect MSSQL is not, so Google a bit, found a solution.

Use the Windows authentication mechanism to go in, and then
Enter the following command to execute:
EXEC sp_password null, ' Newpass ', ' sa '

Example
A. Change the login password without the original password
The following example changes the password for the login Victoria to 123
EXEC sp_password NULL, ' 123 ', ' sa '

B. Change Password
The following example changes the password for the login Victoria from 123 to 456
EXEC sp_password ' 123 ', ' 456 '

Another problem I found was that Windows and SQL Server authentication mechanisms were different
Windows authentication

Server address Landing Results
127.0.0.1 OK
localhost wrong
. Ok

SQL Server Authentication

Server address Landing Results
127.0.0.1 OK
localhost wrong
. Wrong


Another record forget the MySQL password to retrieve the method
If MySQL is running,
First Kill: Killall-term mysqld (if it is windows, call the process Manager directly, end)
Start mysq in Safe mode:
/usr/bin/safe_mysqld--skip-grant-tables &
(under Windows MySQL installation so disk/mysql/bin/safe_mysqld--skip-grant-tables)
You can enter MySQL without the need for a password.
Then it's
>use MySQL
>update User Set Password=password ("New_pass") where user= "root";
>flush privileges;
Re-kill MySQL, the normal way to start MySQL.

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.