1. Go to the official website to download
Download from MySQL official website and
unzip it after downloading (be careful not to put it in a Chinese path, a path with spaces or special characters)
2. Configure environment variables
Right-click on this computer -> Advanced System Settings -> Environment Variables -> Click New in the System Variables column below ->
变量名:MYSQL_HOME
变量值:为MySQL解压的根目录
Find the Path variable in the system variable column and double-click it
%MYSQL_HOME%\bin
3. Configure the MySQL initialization file
Create the initialization file my.ini in the MySQL root directory, namely C:\Tool\mysql-8.0.24-winx64. The content is as follows:
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port=3306
# 设置mysql的安装目录
basedir=C:\Tool\mysql-8.0.24-winx64
# 设置mysql数据库的数据的存放目录
datadir=C:\Tool\mysql-8.0.24-winx64/data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=innodb
Replace the content after the above basedir and datadir with your own path
. Note : It needs to be saved as ANSI encoding----use Notepad to open, save/save as, and select ANSI encoding
4. Initialize MySQL
Right-click cmd, select run as administrator , and execute the following command
mysqld --initialize-insecure
After the above initialization operation is completed, you can see that the data directory is generated under the MySQL root directory
5. Start the MySQL service
Enter services.msc, enter the system service interface, find MySQL, right-click to start
6. Test
Open the command prompt, enter the following command and press Enter, if the following interface appears, the installation and startup of MySQL is successful
mysql -uroot
7. Set password
//第一个root为用户名,第二个root为密码
alter user 'root'@'localhost' identified by 'root';