1. Download MySql
Open the MySql official website https://www.mysql.com/ and click DOWNLOADS
Then find the Community (community version, downloading this is enough) download page
Then select MySQL Community Server
Then Select Operating System, select Microsoft Windows , and select the first one among Other Downloads to download. If you want to download the installation version, click on the MySql Installer picture to jump to the installation version download page.
After clicking Download, you may be prompted to log in. Click No thanks, just start my download here.
2. Configuration and installation
Unzip the downloaded MySql, and then create a my.ini file inside the unzipped file.
Then copy the following content into it. Note: There should be no extra spaces or other characters, otherwise an error (mysql: [ERROR] unknown option) may be reported when logging in to mysql later (note: don’t forget to modify the mysql path )
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
# 绑定IPv4
bind-address=127.0.0.1
# 设置端口号
port=3306
# 设置mysql的安装目录,即解压目录
basedir=D:\developers\environments\mysql-8.0.26-winx64
# 设置数据库的数据存放目录
datadir=D:\developers\environments\mysql-8.0.26-winx64\data
# 设置允许最大连接数
max_connections=200
# 设置允许连接失败次数
max_connect_errors=10
# 设置服务端的默认字符集
character-set-server=utf8
# 创建表使用的默认存储引擎
default-storage-engine=INNODB
# 使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
Then configure the bin directory of MySql into the environment variable, and then execute the following command through cmd to initialize MySql. Be sure to remember root@localhost: the initial password behind , which will be needed when changing the password later.
mysqld --initialize --console
Then execute the following command to install the MySql service ( Note: Installing the service should require permissions and you need to use the administrator cmd . The administrator cmd can be opened by searching cmd and then opening it as an administrator)
mysqld --install MySql --defaults-file="D:\mysql-8.0.26-winx64\my.ini"
At this time, when you view the service list, there will be an additional MySql service (right-click this computer , open the management and find the service under Services and Applications to view the service list)
We start this service, then execute mysql -u root -p in cmd, enter the initial password ( can only be handwritten, cannot be copied, case sensitive )
Then enter the following command to change the password. The last single quote is the password. Don’t forget the semicolon after it.
alter user 'root'@'localhost' identified with mysql_native_password by '123456';
At this point, MySql is ready to use