Install and configure MySQL 5.8 on Windows 10

  1. Download MySQL 8.0 windows zip package

Download address

  1. Extract to installation directory

  2. Add the installation directory / bin to the PATH environment variable

  3. Create a new file my.ini in the installation directory and write the basic configuration

[mysqld]
# 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 is the installation directory
basedir = D:\Program\MySQL  
# datadir is mysql data directory
datadir = D:\DBs\MySQL
# Port number
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
  1. Initialize database
    Execute mysqld --initialize --console
    After execution, the initial default password of root will be printed, such as:
2018-04-20T02: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-04-20T02: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-04-20T02:35:01.508173Z 0 [ERROR] [MY-010340] [Server] Error message file 'D:\Program\MySQL\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-04-20T02:35:05.464644Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: APWCY5ws&hjQ
2018-04-20T02: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, the "apwcy5ws & hjq" in line 4 is the initial password. Before changing the password, you need to remember the password, and later login needs to use it.
6. Installation services
Execute mysqld --install

  1. Login mysql
    mysql -uroot -p
    Then output the previous initial password

  2. Change login password

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

[reprinted from] https://blog.csdn.net/zwj1030711290/article/details/80039780

Tags: MySQL Windows Database SQL

Posted on Fri, 31 Jan 2020 09:38:05 -0800 by trystan