Installation and configuration of MySQL 8.0.17

Time:2021-2-19

This paper records the graphic tutorial of MySQL 8.0.17 installation and configuration for your reference. The specific contents are as follows

1. Download the installation package

Download address: installation package

2. Unzip the installation package to the directory

Here you unzip it to D: / / mysql-8.0.17-winx64
(some of the files in the figure are generated by subsequent installation steps)

3. Configure environment variables

My computer → right click → properties → advanced system settings → environment variables

Click “Edit” to add the address of MySQL bin folder

4. Configuration file

Create a new one in the MySQL folder D: mysql-8.0.17-winx64 my.ini File, write the following information:
(pay attention to change the path for different installation addresses)

[mysqld]
#Set port 3306
port=3306
#Set the installation directory of MySQL
Basedir = D: \ \ mysql-8.0.17-winx64 # remember to use double slash here, single slash I will make mistakes here, but look at other people's tutorial, some are single slash. Try it yourself
#Set the data storage directory of MySQL database
DataDir = D: \ \ mysql-8.0.17-winx64 \ \ data # same here
#Maximum number of connections allowed
max_connections=200
#The number of connection failures allowed. This is to prevent someone from trying to attack the database system from the host
max_connect_errors=10
#The character set used by the server is utf8 by default
character-set-server=utf8
#The default storage engine that will be used when creating new tables
default-storage-engine=INNODB
#The default is "MySQL"_ native_ "Password" plug-in authentication
default_authentication_plugin=mysql_native_password
[mysql]
#Setting the default character set of MySQL client
default-character-set=utf8
[client]
#Set the default port for MySQL client to connect to the server
port=3306
default-character-set=utf8

5. Install MySQL

Open CMD as an administrator, go to the MySQL installation path, and enter the following command to initialize the database:


mysqld --initialize --console

be careful! There is a section in the execution output:

[Note] [MY-010454] [Server] A temporary password is generated for [email protected]: zyNrYHh2yF-E

among [email protected] : the following “zynryhh2yf-e” is the initial password (without the first space). Before changing the password, you need to remember the password, which will be used for subsequent login.

If you close it quickly or don’t remember, it’s OK. Delete the initialized dataDir directory and execute the initialization command again, and it will be regenerated. Of course, you can also use security tools to forcibly change the password. You can use whatever method you like.
Reference: data directory initialization mysqld

6. Installation service

In the installation directory D of MySQL, enter


mysqld --install

The original order should be:Mysqld — install [service name]

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

7. Start MySQL service

Start MySQL:


net start mysql

(stop the service with the command net stop mysql. Uninstall MySQL service by command SC delete MySQL / mysqld – remove)

8. Change password

In the MySQL installation directory D::: mysql-8.0.17-winx64-bin, enter:


mysql -u root -p

Enter the previous password to enter mysql.

Execute the command in MySQL:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_ native_ Password by 'new password';

Modify the password, pay attention to the end of the command; must have, this is the syntax of MySQL

installation is complete

You can check the database installed by default


show databases;

Take a look at the default MySQL user:


select user,host,authentication_string from mysql.user;

The host of administrator root is localhost, which means only localhost login access is allowed. If you want to allow other IP login, you need to add a new host. If you want to allow all IP access, you can directly modify it to “%”

Other operation reference: MySQL create user and authorization

Wonderful topic sharing:

Installation of different versions of MySQL

Installation tutorial of mysql5.7

Installation tutorial of mysql5.6

Installation tutorial of mysql8.0

The above is the whole content of this article, I hope to help you learn, and I hope you can support developer more.

Recommended Today

Implementation example of go operation etcd

etcdIt is an open-source, distributed key value pair data storage system, which provides shared configuration, service registration and discovery. This paper mainly introduces the installation and use of etcd. Etcdetcd introduction etcdIt is an open source and highly available distributed key value storage system developed with go language, which can be used to configure sharing […]