mysql-8.0.11-winx64.zip installation tutorial

Download the zip installation package:

  MySQL8.0 For Windows zip package download address: https://dev.mysql.com/downloads/file/?id=476233 , you can log in after entering the page. Then click "No thanks, just start my download." at the bottom to start the download.

  Or download directly: https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-winx64.zip

Environment: Windows 10

One, install

  1.1, extract the zip package to the installation directory

  For example, my installation directory is: C:\Program Files\MySQL

  1.2, configuration file

  In Windows systems, the default configuration file is the my.ini file (or my-default.ini) in the installation directory. Some configurations need to be configured during the initial installation, and most of them can also be changed after the installation is complete. Of course, in extreme cases, everything can be changed.

  We found that there is no my.ini file in the decompressed directory, it can be created by yourself. Add my.ini to the installation root directory, for example, I am here: C:\Program Files\MySQL\my.ini, and write the basic configuration:

 

[mysqld]
# set port 3306
port=3306
# Set the installation directory of mysql
basedir=C:\Program Files\MySQL
# Set the storage directory for the data of the mysql database
datadir=E:\database\MySQL\Data
# maximum number of connections allowed
max_connections=200
# Allow connection failures. This is to prevent someone from this host trying to attack the database system
max_connect_errors=10
# The character set used by the server defaults to UTF8
character-set-server=utf8
# The default storage engine that will be used when creating new tables
default-storage-engine=INNODB
[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

 

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.

To view all configuration items, please refer to: https://dev.mysql.com/doc/refman/8.0/en/mysqld-option-tables.html

  1.3, initialize the database

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

mysqld --initialize --console

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

C:\Users\Administrator>cd C:\Program Files\MySQL\bin

C:\Program Files\MySQL\bin>mysqld --initialize --console
2018-04-28T15:57:17.087519Z 0 [System] [MY-013169] [Server] C:\Program Files\MySQL\bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as process 4984
2018-04-28T15:57:24.859249Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rI5rvf5x5G,E
2018-04-28T15:57:27.106660Z 0 [System] [MY-013170] [Server] C:\Program Files\MySQL\bin\mysqld.exe (mysqld 8.0.11) initializing of server has completed

C:\Program Files\MySQL\bin>

 

  Notice! There is a paragraph in the execution output:  [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rI5rvf5x5G,E  where "rI5rvf5x5G,E" after root@localhost: is the initial password (excluding the first one) space). Before changing the password, you need to remember this password, which will be used for subsequent logins.

  If you are cheap, close soon, or don't remember, it's okay, 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.

Reference: https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization-mysqld.html

 

  1.4, installation service

Execute the command in the bin directory of the MySQL installation directory (open the cmd command line as an administrator, or Shift + right-click in the installation directory to "open the command line window here"):

mysqld --install [service name]

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 .

Example:

C:\Program Files\MySQL\bin>mysqld --install
Service successfully installed.

C:\Program Files\MySQL\bin>net start mysql
MySQL service is starting..
MySQL service has been started successfully.


C:\Program Files\MySQL\bin>

 

Reference: https://dev.mysql.com/doc/refman/8.0/en/windows-start-service.html

 

Second, change the password and password authentication plugin

 

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

mysql -u root -p
  will prompt you to enter a password at this time, remember the password during the installation in step 1.3 above, fill in the password and you can log in successfully and enter the MySQL command mode.

Before MySQL 8.0.4, execute

SET PASSWORD=PASSWORD('[modified 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 'New password';
Modify the password verification plugin and modify the password at the same time.

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

[mysqld]
default_authentication_plugin=mysql_native_password

Example:

C:\Program Files\MySQL\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.11

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
Query OK, 0 rows affected (0.06 sec)

mysql>

 

refer to: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password

 

  At this point, the installation and deployment is complete. The official said that the test speed MySQL8 is twice as fast as 5.

 

  You can view the database installed by default with the command:

show databases;

use mysql;

show tables;

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql>

 

  In addition, if you need to add an account, or if someone other than the machine accesses MySQL, you also need to set the host of the built-in account. For details, please refer to: MySQL Create User and Authorization

 

Guess you like

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