MySQL5.7 installation and initial password problem

The installation process is the same as that of 5.6, so here is a description of the installation process of 5.6. The main difference in 5.7 is that the initial password is not empty, and how to change the initial password will be described later.
1. There are two types of MySQL installation files, one is in msi format and the other is in zip format. If it is in msi format, you can directly click to install and install it according to the installation prompts it gives (I believe everyone can understand English prompts in English). Generally, MySQL will be installed in the directory C:\Program Files\MySQL\MySQL Server 5.6 Medium; the zip format is decompressed by itself. After decompression, MySQL can be used, but it needs to be configured. After decompression, you can rename the folder and put it in a suitable location. Personally, it is recommended to rename the folder to MySQL Server 5.6 and put it in the C:\Program Files\MySQL path. Of course, you can put it anywhere you want.

After completing the above steps, many users start using MySQL, but the error shown in the figure appears. This is due to no environment variables being configured. Configuring environment variables is very simple:
My Computer->Properties->Advanced->Environment Variables
Select PATH, and add: the path of your mysql bin folder (eg: C:\Program Files\MySQL\MySQL Server 5.6\ bin )
PATH=.......;C:\Program Files\MySQL\MySQL Server 5.6\bin (note that it is appending, not overwriting)


2.4
Don't start mysql after configuring the environment variables, we also You need to modify the configuration file (if there is no configuration, the error in the figure will appear when you start it later!: Error 2 The system cannot find the file), the default configuration file of mysql-5.6.1X is in C:\Program Files\ MySQL\MySQL Server 5.6\my-default.ini, or create a my.ini file yourself,
Modify or add configuration in it (as shown in the figure):
[mysqld]
basedir=C:\Program Files\MySQL\MySQL Server 5.6 (where mysql is located)
datadir=C:\Program Files\MySQL\MySQL Server 5.6\data (where mysql is located ) Directory\data)



Run cmd as an administrator (must run as an administrator, otherwise the permissions are not enough),
enter: cd C:\Program Files\MySQL\MySQL Server 5.6\bin Enter the mysql bin folder (whether there is or not After configuring the environment variables, you must also enter the bin folder, otherwise the service will still report an error after starting the service 2)
Enter mysqld -install (if you do not run it as an administrator, an error will occur due to insufficient permissions: Install/Remove of the Service Denied !) The
installation


is successful After the installation is successful, the service must be started. Continue to enter: net start mysql in cmd (as shown in the figure), the service is started successfully!
At this time, many people will have errors, please see Note:
Note: Error 2 and Error 1067 often appear at this time.
If "Error 2 The system cannot find the file" appears, check whether the configuration file has been modified or whether you have entered the bin directory to operate. If the configuration file has been modified correctly and entered the bin folder, you need to delete mysql first (input mysqld -remove) Reinstall (input mysqld -install);
if error 1067 occurs, it is the configuration file modification error, and confirm whether the configuration file is correct.
If the service does not report any errors or prompts that there are files in the data folder that do not exist, it may be that data has not been created or has no permissions. At this time, you can delete the data folder in the mysql directory. Then execute mysqld -remove, mysqld -install, mysqld -initialize to initialize the data, it will automatically create the data folder and the various folders and file data in it.

3. 7 After the service is started successfully, if it is version 5.6 and below, you can log in, as shown in the figure, enter mysql -u root -p (the first login has no password, just press Enter), the login is successful!

If it is version 5.7 and above, the initial password is randomly generated, so you cannot log in without a password. At this time, we can open it in safe mode, mysqld --skip-grant-tables, at this time, the cursor will keep flashing. Note, don't move, open another command line window.
Log in to mysql -u root -p if
the password is empty, just press Enter;
you can go in
and then use mysql;
(Maybe the previous version of the password is password, 5.7.11 is authentication_string, you can select * from user, check it)
( Old version) update user set password=password("123456") where user="root";
(5.7.11) update user set authentication_string=password("123456") where user="root";
Finally, flush privileges; OK.


Question 1: Use mysql -u root -p v:gNXSw5FTkw to prompt (a mysql restart in the middle may be the reason for the restart, and you can log in under normal circumstances)

Your password has expired. To log in you must change it using a client that supports expired passwords



found a solution in stackoverflow, the connection address: http://stackoverflow.com/questions/33387879/mysql-password-expired-cant-connect

solution:

[root@localhost bin]# ./mysqladmin -uroot - p password
Enter password: //Enter the above v:gNXSw5FTkw
New password: //Re-enter the new password
Confirm new password: //Re-enter the new password

Problem solved!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326450965&siteId=291194637