1: Download MySQL
Official website: https://dev.mysql.com/downloads/mysql/
Select the corresponding download file. (My computer is 64 bits, so this download is a 64-bit download file)
2: Install MySQL
Open the download file to extract to the specified file directory. (I unzip this directory for D:\mysql-5.7.21-winx64)
Open the extracted MySQL file under the root directory to create the My.ini (MySQL config file)
the contents of the My.ini file are as follows:
(It is recommended to copy and paste the following files directly)
You need to change the basedir and datadir paths to MySQL's decompression path.
[mysql]# set MySQL client default character set default-character-set =3306# Set the installation directory for MySQL basedir=d:\mysql-5.7 . -winx64# Set the data storage directory for the MySQL database datadir=d:\mysql-5.7. -winx64\data# Maximum number of connections allowed max_connections=# The character set used by the service side defaults to the 8-bit encoded latin1 character set character-set-server=utf8# The default storage engine that will be used when creating a new table -storage-engine=innodb
View Code
Locate the cmd command prompt and right-click Run as Administrator
Go to MySQL subdirectory bin
Input: mysqld--install (Install) mysqld--initialize (Initialize) net start MySQL (run)
3: Set MySQL login password
Previous versions of MySQL root account default password is not empty, if you log in with a blank password must be an error.
Password Setup steps:
- Save file at the end of the My.ini file by adding "skip-grant-tables" (Cancel permission settings)
- Restart MySQL Service
- CMD Enter Mysql-bin directory, enter mysql-u root-p , return, this time do not need a password to login
- Resets the password. Input use MySQL return
- Enter Update user set Authentication_string=password ("NewPassword") where user= "root"; (new version of MySQL database password field changed to authentication_string)
- Delete my.ini file End " skip-grant-tables" Save file
- Restart the MySQL service to log in to the root account with a new password
——————————————— installation is complete ———————————————
——————————— August 4, 2018 09:33:51 update ——————————
Another way to set the MySQL password.
After the MySQL installation, open the Data folder in the MySQL installation directory, there is a . err file , open with Notepad, you can see that there are lines inside
A temporary password is generated for [email protected]: xxxxxxxx
localhost: The following is the default password, copy this password to log in,
You must reset your password after you have successfully logged in, or you will always be prompted for the following line error.
You must reset your password using the ALTER USER statement before executing this statement.
Perform the following command to reset the password so that it can be used normally. You can refer to the following.
SET PASSWORD = PASSWORD (' NEW PASSWORD ')
MySQL Download and installation (Windows)