MySQL Forgot account password solution

Source: Internet
Author: User
Tags mssql mysql in mysql command line

First off MySQL

Start MySQL using the command line (typically to find the Mysql.ini file)

On Windows Mysql.ini files can be seen by looking at the current MySQL process parameters, specific methods point to this

At the start of the MySQL command line, add:--skip-grant-tables parameter

A few other ways:

1. Send the KILL command to MYSQLD server to turn off MYSQLD server (not kill-9), the file that holds the process ID is usually in the same directory as the MySQL database.
Killall-term mysqld
You must be the root user of Unix or an equivalent user on the server you are running in order to perform this operation. 
2. Use the '--skip-grant-tables ' parameter to start 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 the new password  

Pro-Test, absolutely useful, I just do not know the management password MySQL, is to use this method to change the original password to my own password
FIX: 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 the message doesn't appear, it's right.
4.Open a DOS window again .(Because the DOS window just can't be moved), go to the Mysql\bin directory.
5. Enter MySQL return, if successful, a MySQL prompt will appear >
6. Connection rights database >use MySQL; (> is the original cue, 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 (required steps) >flush privileges;
8. Exit > \q
9. Log out of the system, then enter, open MySQL, use the username root and just set the new password 123456 to login.

It is said that you can modify the user table file directly by using the method:
Turn off mysql,windows under open mysql\data\mysql, there are three files User.frm,user. Myd,user. Myi find a password to the MySQL, replace the corresponding three files, if the user table structure has not changed, generally no one to change, replace the user. MyD can do it.
You can also edit the user directly. MYD, find a hex editor, UltraEdit has this feature. Turn off MySQL and open user. MYD. Change the eight character after the user name root to 565491d704013245, and the new password is 123456. or the hexadecimal number corresponding to them, (left there, a character corresponding two numbers), instead of 00 02 02 02 02 02 02 02, This is the blank password, the editor to the right of the see is an asterisk *, looks like a decimal point. Re-open MySQL, enter root and your new password.
today a little things to go into MSSQL, because it is a long time ago, so forget the password SA, although with Windows authentication can go in, but if the use of PHP connection 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 login Victoria to 123
EXEC sp_password NULL, ' 123 ', ' sa '

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

In addition, I found a problem that Windows and SQL Server authentication mechanisms are somewhat different
Windows authentication

Server Address Login Results
127.0.0.1 OK
localhost wrong
. Ok

SQL Server Authentication

Server Address Login Results
127.0.0.1 OK
localhost wrong
. Wrong


also record the way to retrieve the MySQL password you forgot
If MySQL is running,
First Kill: Killall-term mysqld (if it is windows, directly call up the process Manager, end it)
To start mysq in Safe mode:
/usr/bin/safe_mysqld--skip-grant-tables &
(Windows MySQL installation so disk/mysql/bin/safe_mysqld--skip-grant-tables)
You can go to MySQL without a password.
Then there is
>use MySQL
>update User Set Password=password ("New_pass") where user= "root";
>flush privileges;
Kill MySQL again and start MySQL in a normal way

MySQL Forgot account 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.