MySQL 8.0.11 installation tutorial

Time:2019-11-28

There are many online tutorials, basically the same. However, sometimes the installation of software fails due to one detail. I also integrated many tutorials to install it, so this tutorial may not be generally suitable.

Installation environment: win7

1. Download the zip installation package:

MySQL 8.0 for windows zip package download address: https://dev.mysql.com/downloads/file/? Id = 476233, you can enter the page without logging in. Then click “no thanks, just start my download.” at the bottom to start the download.

2, installation

2.1 unzip the zip package to the installation directory

My decompression is in E: \ software \ MySQL \ mysql-8.0.11-winx64

Extracted file directory

2.2 configure environment variables

Add the bin path under the decompression folder to the variable value, beginning with; and ending with

2.3 configure the initialized my.ini file

We found that the unzipped directory does not have my.ini file, so you can create it yourself. Add my.ini (create a new text file, change the file type to. INI) in the installation root directory, and write the basic configuration:

[mysqld]
#Set 3306 port
port=3306
#Set the installation directory of MySQL
Basedir = e: \ \ software \ \ MySQL \ \ mysql-8.0.11-winx64 ා remember to use double slash here \ \, single slash I will make mistakes here, but read other people's tutorials, some are single slash. Try it yourself
#Set the storage directory of MySQL database data
DataDir = e: \ \ software \ \ MySQL \ \ mysql-8.0.11-winx64 \ \ data
#Maximum 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 defaults to utf8
character-set-server=utf8
#Default storage engine to use when creating new tables
default-storage-engine=INNODB
#Use "MySQL native password" plug-in authentication by default
default_authentication_plugin=mysql_native_password
[mysql]
#Set MySQL client default character set
default-character-set=utf8
[client]
#Set the default port when MySQL client connects to the server
port=3306
default-character-set=utf8

Note: the data directory does not need to be created. It will be created automatically in the next step of initialization.

3. Install MySQL

During installation, you must run CMD as an administrator, otherwise an error will be reported during installation, which will cause the installation to fail

3.1 initialize database

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

mysqld --initialize --console

After execution, the initial default password of root will be printed, such as:


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 [email protected]: 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>

Be careful! There is a section in the execution output: [note] [my-010454] [server] a temporary password is generated for root @ localhost: ri5rvf5x5g, e is the initial password (excluding the first space). Before changing the password, you need to remember the password, which is needed for subsequent login.

If you shut it down or don’t remember, it’s OK. 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 password changes. You can use whatever method you like.

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

3.2 installation services

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

Mysqld -- install [service name]

The following service name can be left blank. 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.

After the installation, you can start the MySQL service with the command net start mysql. Stop the service with the command net stop mysql. By ordersc delete MySQL/mysqld -removeUninstall MySQL service

4. Change password

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

mysql -u root -p

At this time, you will be prompted to enter the password. Remember the password in step 3.1 above when installing. After filling in, you can log in successfully and enter MySQL command mode.

To execute a command in MySQL:

Alter user 'root' @ 'localhost' identified with mysql_native_password by 'new password';

Change the password, pay attention to the end of the command; be sure to have, this is the syntax of MySQL

At this point, the installation and deployment are complete. Officials say the test is twice as fast as 5.

 

You can use the command to view the database installed by default:

 

show databases;

 

use mysql;

 

show tables;

 


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

You can see that MySQL database is initialized by default, and MySQL user information is stored in user table. Let’s take a look at the default MySQL user:


select user,host,authentication_string from mysql.user;

mysql> select user,host,authentication_string from mysql.user;
+------------------+-----------+-------------------------------------------+
| user       | host   | authentication_string           |
+------------------+-----------+-------------------------------------------+
| mysql.infoschema | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.session  | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.sys    | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| root       | localhost | *27C237A977F4F44D3F551F1A673BE14DFD232961 |
+------------------+-----------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql>

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

Create user:


CREATE USER 'xxh'@'%' IDENTIFIED WITH mysql_native_password BY '[email protected]#';

#(Note: mysql8.0 encryption mode has been modified)
#Check users


select user, host, plugin, authentication_string from user\G;

Authorize remote database

#Authorize all permissions 
GRANT ALL PRIVILEGES ON *.* TO 'xxh'@'%';
#Authorize basic query and modification permissions, set as required
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON *.* TO 'xxh'@'%';

view user permission

show grants for 'xxh'@'%';

Example:

mysql> use mysql;
Database changed
MySQL > create user 'Xxh' @ '%' identified with MySQL ﹣ create user (Note: mysql8.0 encryption method has been modified)
Query OK, 0 rows affected (0.07 sec)
mysql>

View password encryption method:


mysql> select user, host, plugin, authentication_string from user;
+------------------+-----------+-----------------------+-------------------------------------------+
| user       | host   | plugin        | authentication_string           |
+------------------+-----------+-----------------------+-------------------------------------------+
| xxh       | %     | mysql_native_password | *70FD6FB4F675E08FF785A754755B5EBA6DA62851 |
| mysql.infoschema | localhost | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.session  | localhost | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.sys    | localhost | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| root       | localhost | mysql_native_password | *27C237A977F4F44D3F551F1A673BE14DFD232961 |
+------------------+-----------+-----------------------+-------------------------------------------+
5 rows in set (0.00 sec)

mysql>

summary

The above is the text explanation of MySQL 8.0.11 installation tutorial that Xiaobian introduced to you. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply you in time!