Win10+MySQL8.0 installation record and pit guide

This article directory:

1. Installation

2. Change password and password authentication plugin

3. Guide to circumnavigating the pit

    1.Can't connect to MySQL server on 'localhost'

     2.Install/Remove of the Service Denied!错误


1. Installation

First, the Windows zip package download address:

1. Unzip the zip package to the installation directory

My installation directory is D:\mysql-8.0.11-winx64

2. Configuration file

The configuration file in the windows system is the my.ini file in the installation directory by default   . Some configurations need to be configured during the initial installation, and most of them can also be changed after the installation is complete. I don’t know what others are doing, but mine is in this file directory. The my.ini file does not exist, so I created it as follows


Write the basic configuration as follows:

[mysqld]
default_authentication_plugin=mysql_native_password
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir=D:\mysql-8.0.11-winx64
datadir=D:\mysql-8.0.11-winx64\data (These two lines are the main modifications, the data folder will be automatically generated, and the others can be pasted directly)
port = 3306
# server_id = .....


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

character-set-server = utf8mb4

performance_schema_max_table_instances = 600
table_definition_cache = 400
table_open_cache = 256

[mysql]
default-character-set = utf8mb4

[client]
default-character-set = utf8mb4

Note that basedir is my local installation directory, datadir is the location where my database data files are stored, and each configuration needs to be configured according to your own environment.

3. Initialize the database

Execute the command in the bin directory of the MySQL installation directory: ( Do not close the window after execution! )

mysqld --initialize --console

After the execution is complete, the initial default password of the root user will be printed, for example:

2018-05-01T14:35:01.507037Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2018-05-01T14:35:01.507640Z 0 [System] [MY-013169] [Server] D:\Program\MySQL8\bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as process 11064 2018-05-01T14:35:01.508173Z 0 [ERROR] [MY-010340] [Server] Error message file 'D:\Program Files\mysql-8.0.11-winx64\share\english\errmsg.sys' had only 1090 error messages, but it should contain at least 4512 error messages. Check that the above file is the right version for this program! 2018-05-01T14:35:05.464644Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: APWCY5ws&hjQ 2018-05-01T14:35:07.017280Z 0 [System] [MY-013170] [Server] D:\Program\MySQL8\bin\mysqld.exe (mysqld 8.0.11) initializing of server has completed

Among them, "APWCY5ws&hjQ" in line 4 is the initial password. Before changing the password, you need to remember this password and use it for subsequent logins.

If you are cheap, close soon, or don't remember, that's fine, delete the initialized datadir directory, execute the initialization command again, and it will be regenerated. Of course, you can also use security tools to force the password change, and you can use any method you want.

4. Installation service

Execute the command in the bin directory of the MySQL installation directory:

mysqld --install [服务名]

The following service name can be omitted, and the default name is mysql. Of course, if you need to install multiple MySQL services on your computer, you can use different names to distinguish them, such as mysql5 and mysql8.

After the installation is complete, you can start the MySQL service through the command net start mysql. 

2. Change password and password authentication plugin

Execute the command in the bin directory of the MySQL installation directory:

mysql -uroot -p

At this time, you will be prompted to enter a password, remember the password in step 3, fill it in, you can log in successfully, and enter the MySQL command mode

Before MySQL 8.0.4, execute

SET PASSWORD=PASSWORD('[修改的密码]');

You can change the password, but starting from MySQL 8.0.4, this is not possible by default. Because before, MySQL's password authentication plugin was "mysql_native_password", and now it uses "caching_sha2_password".

Because many database tools and link packages currently do not support "caching_sha2_password", for the sake of convenience, I have temporarily changed back to the "mysql_native_password" authentication plugin.

Execute the command in MySQL:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';(注意一定要有分号)(注意一定要有分号)

Modify the password verification plug-in, and modify the password at the same time.

If you want to use the "mysql_native_password" plugin authentication by default, you can configure default_authentication_pluginitems in the configuration file.

[mysqld]
default_authentication_plugin=mysql_native_password

3. Guide around the pit

1.Can't connect to MySQL server on 'localhost'

First rule out the wrong password input.

右键“计算机”——>“管理”然后点击“服务”,在右侧找到“MySQL服务,右键启动即可


2.Install/Remove of the Service Denied!错误

打开cmd.exe程序的时候选择“用管理员身份打开”。

以上是安装过程中发现的两个问题,如果遇到其他问题欢迎互相讨论~

本文参考文献: windows10+mysql8.0.11zip安装

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325818888&siteId=291194637