Article directory
1. MySQL download
First open the MySQL official website. The home page address of the official website is the
home page address of the MySQL official website.
After entering the official website, as shown in the figure below, click DOWNLOADS to enter the download page.
Scroll down the page to find **MySQL Community (GPL) Downloads>>** and click
Next click MySQL Community Server
If you want to install a previous version of MySQL, click Archives
After entering the page, you can easily find the MySQL version you want to download.
Here I downloaded the installation-free version, click on it and log in to download.
2. Install and configure MySQL
Unzip the compressed package to the folder where you want to place it,Note: Avoid Chinese characters in the absolute path. Here, the author unzipped the compressed package in the software folder of the D drive.
Create a new my.ini file in the unzipped directory
Enter the following text in the file: (Note that the contents of the installation directories basedir and datadir should be written to the path of your own installation. Do not create the Data folder manually, it will be created automatically.)
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\\software\mysql-8.0.32-winx64
# 设置mysql数据库的数据的存放目录,data文件夹它会自行创建,不要自己手动创建
datadir= D:\\software\mysql-8.0.32-winx64\Data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
After initializing MySQL,Run cmd as administrator, to avoid installation failure.
After opening cmd, first enter d: to enter the D drive (Whichever disk your MySQL is installed on?)
d:
Then enter cd D:\software\mysql-8.0.32-winx64\bin to enter the MySQL bin directory (Note that you need to enter your own MySQL bin directory)
cd D:\software\mysql-8.0.32-winx64\bin
Then execute the following command in the bin directory: mysqld --initialize --console
mysqld --initialize --console
Note : root@localhost: -qbm2FYOI9oU (the one marked in the picture below, everyone is different) is the initial password (does not include the first space). You need to copy and save this (do not type it by hand to avoid errors), and you will use it later (-qbm2FYOI9oU )
After installing the MySQL service, execute the following command: mysqld --install
mysqld --install
Start the MySQL service and execute the following command: net start mysql
net start mysql
Connect to MySQL and execute the following command: mysql -uroot -p
mysql -uroot -p
The initial password is used in this step
change Password(The single quotation mark 123456 behind is the password set by the author myself. Readers can set it according to their own interests and hobbies). Execute the following command: ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
3. Configure MySQL environment variables
Configure MySQL environment variables: Right-click this computer–>Properties–>Advanced system settings
Click on environment variables
Add the MySQL bin path to the path of the system variable (Note: The path here is your own MySQL bin path)
Click OK when finished .
4. Create a new database
Open Navicat–>Click on the connection– >Click on MySQL– >Name the connection Shoptest, and the password is 123456 (this is the author’s database password, please use the one you set in front of the screen)–>Open this connection again.
OK! ! ! Finish