Detailed steps for installing and configuring MySQL 8.0 on CentOS 7.4 64-bit

Detailed steps for installing and configuring MySQL 8.0 on CentOS 7.4 64-bit

Step 1: Get the MySQL YUM source

Go to the MySQL official website to obtain the RPM package download address

https://dev.mysql.com/downloads/repo/yum/

Click to download

Get the download link:

https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

--------------------------------------------------------------------------------

Step 2: Download and install MySQL source

• Enter the mysql folder and create one if it doesn’t exist

[root@VM_0_10_centos /]# cd /usr/local/mysql/
[root@VM_0_10_centos mysql]#

• Download source installation package

[root@VM_0_10_centos mysql]# wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
--2018-08-04 10:29:39-- https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.219.33.198
Connecting to repo.mysql.com (repo.mysql.com)|23.219.33.198|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25820 (25K) [application/x-redhat-package-manager]
Saving to: 'mysql80-community-release-el7-1.noarch.rpm'
100%[============================================================================>] 25,820 112KB/s in 0.2s 
2018-08-04 10:29:40 (112 KB/s) - 'mysql80-community-release-el7-1.noarch.rpm' saved [25820/25820]
[root@VM_0_10_centos mysql]# ll
total 28
-rw-r--r-- 1 root root 25820 Apr 18 13:24 mysql80-community-release-el7-1.noarch.rpm
[root@VM_0_10_centos mysql]#

• Install mysql source

[root@VM_0_10_centos mysql]# yum -y localinstall mysql80-community-release-el7-1.noarch.rpm

Step 3: Install MySQL online

[root@VM_0_10_centos mysql]# yum -y install mysql-community-server

There is a lot to download, please wait a few minutes.

Step 4: Start the Mysql service

[root@VM_0_10_centos mysql]# systemctl start mysqld

Step 5: Set up startup

[root@VM_0_10_centos mysql]# systemctl enable mysqld
[root@VM_0_10_centos mysql]# systemctl daemon-reload

Step 6: Change the root local login password

After mysql is installed, a temporary default password is generated for root in the /var/log/mysqld.log file. Search with the grep command

[root@VM_0_10_centos mysql]# grep "A temporary password is generated for root@localhost" /var/log/mysqld.log 
2018-08-02T02:19:55.829527Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: !J:KUwU9y0ZR
2018-08-02T04:49:34.979689Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pw</s9,Wivm2
2018-08-04T02:40:46.781768Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: nNyK,Y)Wd0-G
[root@VM_0_10_centos mysql]#

There are three search results here because I installed MySQL three times. If it was the first installation, there would only be one search result.

Directly get the temporary default password: nNyK,Y)Wd0-G

• Login to MySQL

[root@VM_0_10_centos mysql]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.12
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>

•Change the temporary password of the root account

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '[email protected]';
Query OK, 0 rows affected (0.03 sec)
mysql>

[email protected] Please replace it with your own password.

(Note: The default password policy of MySQL 8.0 requires that the password must be a combination of uppercase and lowercase letters, numbers and special letters, and at least 8 characters)

Step 7: Create a new user, authorize, and log in remotely (do not log in directly using the root account)

• Create easyoh-mp user and authorize remote login

mysql> CREATE USER 'easyoh-mp'@'%' IDENTIFIED BY '[email protected]';
Query OK, 0 rows affected (0.04 sec)
mysql> GRANT ALL ON *.* TO 'easyoh-mp'@'%';
Query OK, 0 rows affected (0.03 sec)
mysql>

•Log in with the easyoh-mp account on the sqlyog client (other clients are also acceptable)

It is found that plugin caching_sha2_password error will be reported. This is because the MySQL 8.0 password policy defaults to caching_sha2_password. Different from 5.7.

• Enter the MySQL database to query user table information

mysql> use mysql;
Database changed
mysql> select user,host,plugin from user;
+------------------+------------+-----------------------+
| user | host | plugin |
+------------------+------------+-----------------------+
| easyoh-mp | % | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------------------+------------+-----------------------+
5 rows in set (0.00 sec)
mysql>

It turns out that it is indeed caching_sha2_password

• Execute the following statements in sequence

mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED BY '[email protected]' PASSWORD EXPIRE NEVER; 
Query OK, 0 rows affected (0.04 sec)
mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED WITH mysql_native_password BY '[email protected]'; 
Query OK, 0 rows affected (0.05 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql>

Log in again and you will be logged in successfully.

Step 8: Coding

mysql> show variables like '%character%';
+--------------------------+--------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql-8.0/charsets/ |
+--------------------------+--------------------------------+
8 rows in set (0.01 sec)
mysql>

The default encoding for MySQL 8.0 is utf8mb4 and no change is required.

OK. At this point, the Mysql installation and configuration is complete;

Full process operation record

[root@VM_0_10_centos ~]# 
[root@VM_0_10_centos /]# cd /usr/local/mysql/
[root@VM_0_10_centos mysql]# wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
--2018-08-04 10:29:39-- https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.219.33.198
Connecting to repo.mysql.com (repo.mysql.com)|23.219.33.198|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25820 (25K) [application/x-redhat-package-manager]
Saving to: 'mysql80-community-release-el7-1.noarch.rpm'
100%[============================================================================>] 25,820 112KB/s in 0.2s 
2018-08-04 10:29:40 (112 KB/s) - 'mysql80-community-release-el7-1.noarch.rpm' saved [25820/25820]
[root@VM_0_10_centos mysql]# ll
total 28
-rw-r--r-- 1 root root 25820 Apr 18 13:24 mysql80-community-release-el7-1.noarch.rpm
[root@VM_0_10_centos mysql]# yum -y localinstall mysql80-community-release-el7-1.noarch.rpm 
Loaded plugins: fastestmirror, langpacks
Examining mysql80-community-release-el7-1.noarch.rpm: mysql80-community-release-el7-1.noarch
Marking mysql80-community-release-el7-1.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================================================
 Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
 mysql80-community-release noarch el7-1 /mysql80-community-release-el7-1.noarch 31 k
Transaction Summary
=================================================================================================================================================================================================================
Install 1 Package
Total size: 31 k
Installed size: 31 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
 Installing:mysql80-community-release-el7-1.noarch 1/1 
 Verifying : mysql80-community-release-el7-1.noarch 1/1 
Installed:
 mysql80-community-release.noarch 0:el7-1                     
Complete!
[root@VM_0_10_centos mysql]# yum -y install mysql-community-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel 12641/12641
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:8.0.12-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 8.0.12-1.el7 for package: mysql-community-server-8.0.12-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 8.0.0 for package: mysql-community-server-8.0.12-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:8.0.12-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.0 for package: mysql-community-client-8.0.12-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:8.0.12-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:8.0.12-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================================================
 Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
 mysql-community-server x86_64 8.0.12-1.el7 mysql80-community 349 M
Installing for dependencies:
 mysql-community-client x86_64 8.0.12-1.el7 mysql80-community 26 M
 mysql-community-common x86_64 8.0.12-1.el7 mysql80-community 541 k
 mysql-community-libs x86_64 8.0.12-1.el7 mysql80-community 2.2 M
Transaction Summary
=================================================================================================================================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 377 M
Installed size: 1.7 G
Downloading packages:
(1/4): mysql-community-common-8.0.12-1.el7.x86_64.rpm | 541 kB 00:00:05 
(2/4): mysql-community-client-8.0.12-1.el7.x86_64.rpm | 26 MB 00:00:12 
(3/4): mysql-community-server-8.0.12-1.el7.x86_64.rpm | 349 MB 00:02:26 
(4/4): mysql-community-libs-8.0.12-1.el7.x86_64.rpm | 2.2 MB 00:03:37 
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.7 MB/s | 377 MB 00:03:43 
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing: mysql-community-common-8.0.12-1.el7.x86_64 1/4 
 Installing: mysql-community-libs-8.0.12-1.el7.x86_64 2/4 
 Installing: mysql-community-client-8.0.12-1.el7.x86_64 3/4 
 Installing: mysql-community-server-8.0.12-1.el7.x86_64 4/4 
 Verifying : mysql-community-common-8.0.12-1.el7.x86_64 1/4 
 Verifying : mysql-community-libs-8.0.12-1.el7.x86_64 2/4 
 Verifying : mysql-community-client-8.0.12-1.el7.x86_64 3/4 
 Verifying : mysql-community-server-8.0.12-1.el7.x86_64 4/4 
Installed:
 mysql-community-server.x86_64 0:8.0.12-1.el7                     
Dependency Installed:
 mysql-community-client.x86_64 0:8.0.12-1.el7 mysql-community-common.x86_64 0:8.0.12-1.el7 mysql-community-libs.x86_64 0:8.0.12-1.el7    
Complete!
[root@VM_0_10_centos mysql]# systemctl start mysqld
[root@VM_0_10_centos mysql]# systemctl enable mysqld
[root@VM_0_10_centos mysql]# systemctl daemon-reload
[root@VM_0_10_centos mysql]# grep "A temporary password is generated for root@localhost" /var/log/mysqld.log 
2018-08-02T02:19:55.829527Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: !J:KUwU9y0ZR
2018-08-02T04:49:34.979689Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pw</s9,Wivm2
2018-08-04T02:40:46.781768Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: nNyK,Y)Wd0-G
[root@VM_0_10_centos mysql]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.12
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 BY '[email protected]';
Query OK, 0 rows affected (0.03 sec)
mysql> CREATE USER 'easyoh-mp'@'%' IDENTIFIED BY '[email protected]';
Query OK, 0 rows affected (0.04 sec)
mysql> GRANT ALL ON *.* TO 'easyoh-mp'@'%';
Query OK, 0 rows affected (0.03 sec)
mysql> use mysql;
Database changed
mysql> select user,host,plugin from user;
+------------------+------------+-----------------------+
| user | host | plugin |
+------------------+------------+-----------------------+
| easyoh-mp | % | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------------------+------------+-----------------------+
5 rows in set (0.00 sec)
mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED BY '[email protected]' PASSWORD EXPIRE NEVER; 
Query OK, 0 rows affected (0.04 sec)
mysql> ALTER USER 'easyoh-mp'@'%' IDENTIFIED WITH mysql_native_password BY '[email protected]'; 
Query OK, 0 rows affected (0.05 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> show variables like '%character%';
+--------------------------+--------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql-8.0/charsets/ |
+--------------------------+--------------------------------+
8 rows in set (0.01 sec)

There is a problem here. If the new password is set too simply, an error will be reported:

The reason is that MySQL has password setting specifications, which are specifically related to the value of validate_password_policy:

The complete initial password rules for MySQL can be viewed using the following command:

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 4 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.01 sec)

The length of the password is determined by validate_password_length, and the calculation formula for validate_password_length is:

validate_password_length = validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)

Mine has been modified. Initially, the first value is ON and validate_password_length is 8. It can be modified by the following command:

mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;

Summarize

The above is the detailed steps for installing and configuring MySQL 8.0 on CentOS 7.4 64-bit. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • CentOS 6.4 MySQL 5.7.18 installation and configuration method graphic tutorial
  • Deploy MySQL 5.7.17 binary installation and multi-instance configuration on CentOS 6.5
  • MySQL 5.7.17 installation and configuration method graphic tutorial (CentOS7)
  • Configure MySQL source and install MySQL using yum under CentOS 7
  • Installation and configuration of MySQL under CentOS 7.2
  • Tutorial on installing and configuring MySQL in Alibaba Cloud's CentOS environment
  • Configuration example of installing multiple mysql data in Centos
  • CentOS 6.4 installation and configuration of LAMP server (Apache+PHP5+MySQL)
  • CentOS 6.4 installation and configuration of LNMP server (Nginx+PHP+MySQL)
  • CentOS 5.4 server configuration yum install Apache+php+MySQL

<<:  Detailed explanation of the principle of js Proxy

>>:  Linux 6 steps to change the default remote port number of ssh

Recommend

MySQL data compression performance comparison details

Table of contents 1. Test environment 1.1 Hardwar...

The vue project realizes drawing a watermark in a certain area

This article shares with you how to use Vue to dr...

Detailed explanation of loop usage in javascript examples

I was bored and sorted out some simple exercises ...

How to implement page jump in Vue project

Table of contents 1. Create a vue-cli default pro...

MySQL database backup and recovery implementation code

Database backup #grammar: # mysqldump -h server-u...

Perfect solution for vertical centering of form elements

Copy code The code is as follows: <!DOCTYPE ht...

How to implement web page compression in Nginx optimization service

Configure web page compression to save resources ...

Mysql table creation foreign key error solution

Database Table A: CREATE TABLE task_desc_tab ( id...

Detailed explanation of docker's high availability configuration

Docker Compose Docker Compose divides the managed...

How to implement a password strength detector in react

Table of contents Preface use Component Writing D...

Recommended plugins and usage examples for vue unit testing

Table of contents frame First-class error reporti...

Vue2/vue3 routing permission management method example

1. There are generally two methods for Vue routin...

Front-end AI cutting tips (experience)

AI image cutting needs to be coordinated with PS....

jQuery implements employee management registration page

This article example shares the specific code of ...