What I installed here is MySQL 5.7.43. The following is a detailed download, installation and configuration tutorial.
1. Download steps
- Enter the official website: https://www.mysql.com/
- Scroll to the bottom of the homepage and find MySQL Community server
- Select the version you want and the corresponding computer configuration to download.
- After downloading, unzip it to the directory you want to save.
2. Configure environment variables
1. Right-click this computer->Properties->Advanced system settings->Environment variables->System variables
2. Create a new system variable
Variable name: MYSQL_HOME
Variable value: D:\MySQL\mysql-5.7.43-winx64
3. Add the newly created system variable to Path
%MYSQL_HOME%\bin
4. Configure the my.ini file.
Create a new my.ini file.
The contents of the my.ini file:
[mysqld]
#端口号
port = 3306
#mysql-5.7.43-winx64的路径
basedir=D:\MySQL\mysql-5.7.43-winx64
#mysql-5.7.43-winx64的路径+\data
datadir=D:\MySQL\mysql-5.7.43-winx64\data
#最大连接数
max_connections=200
#编码
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysql]
#编码
default-character-set=utf8
5. Install MySQL
① Enter cmd in the search box and run as administrator
② Enter the MySQL installation directory D:\MySQL\mysql-5.7.43-winx64 in cmd
and enter the installation command: mysqld -install . If Service successfully installed appears, it is proved The installation is successful; if Install of the Service Denied appears, it means that cmd is not running with administrator privileges:
continue to enter the command: mysqld --initialize to initialize the database
and then enter the startup command: net start mysql . The following prompt appears to prove that MySQL is started successfully:
6.Set MySQL password
- Setting the password is mainly used to solve the problem of ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
- To stop the MySQL service, enter the command line net stop mysql :
- Find the my.ini file you just created and add skip-grant-tables
- Restart MySQL through the command net start mysql
- Then enter the command mysql -u root -p . There is no need to enter a password. Just press Enter to enter MySQL.
- Enter the command line use mysql , enter the database,
and then enter the command line to change your MySQL password:
update user set authentication_string=password("ping1212") where user="root";
7. Stop the MySQL service and enter service in the system search box. Find MySQL. Just right-click and click Stop. 8. Then delete skip-grant-tables
in the my.ini file just now , start cmd again (as administrator), enter the startup command: net start mysql , then enter mysql -u root -p , and then enter the value you just set Password, the following information appears to prove that the setting is successful! 9. Enter the command use mysql , and it will prompt that you need to reset the password. 10. Enter the command: alter user user() identified by “ping1212”; My password is: ping1212 Enter the command line use mysql again . The following prompt means the installation is successful!