MySQL is a relational database management system developed by MySQL AB, a Swedish company. In 2008, iT was acquired by SUN, which was later acquired by Oracle.

A, download

MySQL’s official website www.mysql.com/

Click on DOWNLOADS to go to the download address and you’ll see several different versions:

  • MySQL Enterprise Edition: Enterprise Edition
  • MySQL Cluster CGE: Advanced Cluster Edition
  • MySQL Community Edition: Community Edition

Usually we use the community edition. Click on the Community edition, see a lot of things, a little surprised, don’t worry, actually click on the first MySQL Community Server download.

So the real download address is: dev.mysql.com/downloads/m…

Drag it down and select Windows.

The installer and unzipped versions are available. The installer is 32-bit (of course, you can install it on a 64-bit system) and the unzipped version is 64-bit.

Click Download and you will be redirected to the following page, which asks you to register/log in. Ignore it and click No Thanks, just start my Download. Start downloading.

Two, decompressed version configuration

1. Configure environment variables

Unzip the installation package to the directory you want to install and add the bin directory to the environment variable.

2. Configure my.ini

Create a new my.ini file in the root directory.

Add the following configuration to my.ini:

[mysqld]
; Example Set port 3306
port=3306
; Set the mysql installation directory
basedir=C:\\gl\\SQL\\mysql-8.0.18-winx64
; Example Set the directory where the mysql database data is stored
datadir=C:\\gl\\SQL\\mysql-data
; Maximum number of connections allowed
max_connections=200
; The number of connection failures allowed. This is to prevent someone from the host from trying to attack the database system
max_connect_errors=10
; The default character set used by the server is UTF8
character-set-server=utf8
; The default storage engine to use when creating new tables
default-storage-engine=INNODB
; The mysql_native_password plug-in is used for authentication by default
default_authentication_plugin=mysql_native_password
[mysql]
; Set the default character set of the mysql client
default-character-set=utf8
[client]
; Set the default port used by the mysql client to connect to the server
port=3306
default-character-set=utf8
Copy the code

Note: Basedir and Datadir should be changed to your own directory.

Trap:

Default_authentication_plugin =mysql_native_password must be added; otherwise, the initial password of root may fail to log in.

Initialize the database

Run CMD as the administrator, go to the bin directory of the installation directory, and run the following command:

mysqld --initialize --console
Copy the code

The default service name is mysql, or you can specify a service name

Mysqld --initialize --console service nameCopy the code

It is not usual to specify a service name, but if you need to install multiple MySQL services on your computer, you can use different names to distinguish them.

After the command is executed successfully, the initial password of root is displayed, as shown in the following figure. You need to save the password.

If you do not add –console to the command, no log information is displayed in the CMD window. You can go to the data directory (where datadir is configured in my.ini) to find a.err file, or you can view the log information.

Trap 1

It might say “msvcp140.dll not found”

Msvcp140.dll is a component file of Visual Studio C++ 2015 Redistributable.

Visual C++ Redistributable for Visual Studio 2015 is not installed. This must be installed, or later services will not start. Download: www.microsoft.com/zh-CN/downl…

If it is installed, you can fix it.

Alternatively, download an Msvcp140.dll, copy it to C:\Windows\System32, and run the following batch command to register the DLL

@echoStart registering copy msvcp140.dll %windir%\ System32\ regsvr32% windir%\ System32\ msvcp140.dll/s@echoMsvcp140.dll registered successfully @pauseCopy the code

After registering successfully, run the above MySQL command to initialize the database normally. Certainly not recommended.


Trap 2

After the execution is complete, check the output carefully and the following warnings may appear:

'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Copy the code

Utf 8 is currently an alias for character set UTF8MB3 and will be replaced by UTF8MB4 in future releases. Consider using UTF8MB4 for clarity.

If so, we simply replace utf8 with UTF8MB4 in the my.ini file.

3.2 installation services

Installation services:

mysqld -install
Copy the code

Start the service:

net start mysql
Copy the code

If you specified a different service name in the previous step, change mysql to the service name you specified.

Logging in to the database:

mysql -u root -p
Copy the code

You will be prompted to enter your password, which is the password you saved above.

If the login is successful, the following information is displayed:

Change the password: Run the following statement to change the password to root.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
Copy the code