Mysql installation and configuration tutorial under windows

Mysql download

Download mysql community server from the official website
https://dev.mysql.com/downloads/mysql/
. You can choose to download the compressed package or MSI installer.
Insert image description here

Install using compressed package

MySQL compressed package installation usually requires the following steps:

1. Download the MySQL installation package

You can download the MySQL installation package suitable for your system from the MySQL official website, and select the appropriate version to download.

Download mysql8.0 or above version here

Insert image description here

Unzip: Unzip the downloaded MySQL installation package to the target path, which contains the following files

Insert image description here

2. Configure environment variables: add the bin folder path under the mysql folder to the system variable Path

Note that there are many paths in path. Add them at the end. Do not delete the previous ones, otherwise it will cause a series of consequences such as system crash. If there is an edit box in the form of a list, just create a new line and add it. There is no need to consider other issues. If it is directly To edit text, ;separate multiple paths with;

Insert image description here

Insert image description here

3. Configure the initialization configuration file my.ini: create my.ini in the root directory of the mysql folder (modify it directly if it exists)

Insert image description here

The configuration content of my.ini is as follows, which should be modified according to the actual installation situation.

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\mysql-8.0.23-winx64   
# 设置mysql数据库的数据的存放目录
datadir=D:\mysql-8.0.23-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
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8

4. Install mysql service

Right-click the start menu and select command line or powershell (administrator). How to open powershell and enter cmd to switch to the command line?
Insert image description here
Insert image description here

mysqld --initialize --console

Insert image description here

Don’t close the window after running it

mysqld --install [服务名]

Start service

net start mysql

Insert image description here

Log in to mysql
and enter the following command to log in, and then enter the password. Here you need to use the password in the above initialization.

mysql -u root -p

Insert image description here
change Password

Enter the following command. xxxx is the new password to be changed. It must be added at the end ;, otherwise the command will not be executed.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxx'; 

result:

Query OK, 0 rows affected (0.01 sec)

Install using the installation package MSI

Using msi to install mysql simplifies some installation steps and is suitable for novices

Download the installation package from the official website

Insert image description here

Install

Select setting type

Typical typical installation: install the most common program functions. Recommended for most users.

Custom installation (according to personal needs): allows users to choose which program functions will be installed and where to install them. It is recommended for advanced users.

Complete installation: All program features will be installed and require the most disk space.

Insert image description here

Select Custom installation, you can modify the installation path, if not needed, select typical

Insert image description here

Click OK for typical installation, and the installation will be completed automatically. After the installation is completed, select Run MYSQL Configuration

Insert image description here

Configuration

When the installation is complete, you will be prompted to enter the configuration interface.

Insert image description here

Set the network configuration and select the default port 3306
Insert image description here

Enter the password for the administrator account root (compared to compressed package installation, it eliminates the need to find the initialization password and then change the password)

Insert image description here

windows service

Select the default configuration and change the service name

Insert image description here

Follow the default configuration

Insert image description here

Insert image description here

ClickExecute
Insert image description here

After completion, next, then finish.
Insert image description here

test

After the configuration is completed, use the tool to connect. Here, use navicat to test the link. If the connection is successful, it means the installation and configuration are correct.

Insert image description here

Guess you like

Origin blog.csdn.net/qq_39427511/article/details/132544058