Install mysql5.7.16 under WINDOW7, a problem occurs when initializing, a password is generated by default, which causes the database to not be connected. Before 5.7, the default password is empty, you can enter the database without a password. After 5.7, we have a pit, and here we get the initial password.
1, the new My.ini, put to C:\windows below, the file content is as follows:
port=3306 basedir=d:\dev\mysql\mysql-5.7.9-winx64 Datadir=d:\dev\mysql\mysql-5.7.9-winx64\data max_connections= 200character-set-server=utf8 Default-storage-engine=innodb
2. Create a new Data folder in the MySQL directory
3. Get the initial password command as follows:
Command
A password will appear, write down this password, when connecting to the database, enter the password can be changed.
4. Start the service
Command: net start MySQL
The normal situation will prompt you to start the success, (note: Some will not start 3534, this is because there is no data file under the directory, this time you have to first command init);
5. Then the second command, we log in to MySQL:
Command: Mysql-uroot-p
Will prompt you to enter the password, is the above we see the default password, after entering the normal situation will have welcome and so on prompt
6, start to modify the default password, and then enter:
Command: Use MySQL
You will then be prompted: ERROR 1820 (HY000): You must the reset your password using ALTER USER statement before executing this statement.
Don't worry, we'll enter the command:
Command: Alter user ' root ' @ ' localhost ' identified by ' MySQL ';
You will then be prompted to query OK!.
Here is a formal modification of our password, here is a place to note, 5.7.9 version of the user table there is no password this field, you can look at
But here is an encrypted authentication_string field, this is the new version of the password, since we found that we are not welcome, change the password:
Update user set authentication_string= "123456" where user= "root";
Then we look at it, basically normal:
Note: Here a lot of people will think that set up, directly knocking command: flush privileges; and then quit the restart login, the results will find that the password is not used, the landlord is also here to eat a dark loss, stopped for a period of time not its solution, Baidu after the discovery need to set the following:
SET PASSWORD = PASSWORD (' 123456 ');
PASSWORD write the new password you just set;
This time we can flush:
Flush privileges;
Then exit:
Exit
So that we can successfully set up our new password.
Well, let's verify that I'm going to continue typing in the cmd command window:
Mysql-uroot-p
Then enter the password (your new password) and it will normally be OK.
mysql5.7.16 Install initial password acquisition and password reset