This is the seventh day of my participation in the August More text Challenge. For details, see:August is more challenging

The body of the

1. Prepare the mysql RPM package

Mysql – community – the client – plugins – 8.0.24-1. El8. X86_64. RPM

Mysql – community – libs – 8.0.24-1. El8. X86_64. RPM

Mysql – community – common – 8.0.24-1. El8. X86_64. RPM

Mysql – community – the client – 8.0.24-1. El8. X86_64. RPM

Mysql – community – server – 8.0.24-1. El8. X86_64. RPM

2. Install mysql – community – the client

[root@node2 hadoop]# ll total usage 70092-rwxr-xr-x. 1 Hadoop 14052636 June 19 19:28 Mysql-community-client-8.0.24-1.el8.x86_64. RPM -rwxr-xr-x. 1 Hadoop hadoop 100356 6月 19 19:41 Mysql-community-client-plugins-8.0.24-1.el8.x86_64.rpm -rwxr-xr-x. 1 Hadoop hadoop 632772 June 19 19:28 Mysql-community-common-8.0.24-1.el8.x86_64. RPM -rwxr-xr-x. 1 Hadoop hadoop 1497724 June 19 19:37 Mysql-community-libs-8.0.24-1.el8.x86_64.rpm -rwxr-xr-x. 1 Hadoop hadoop 55483196 March 23 19:55 Mysql -community-server-8.0.24-1.el8.x86_64. RPM [root@node2 hadoop]# RPM -ivh Mysql-community-common-8.0.24-1.el8.x86_64. RPM: mysql-community-common-8.0.24-1.el8.x86_64. RPM: Header V3 DSA/SHA1 Signature, key ID 5072E1F5: NOKEY Verifying... ################################# [100%] Preparing... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%] package mysql - community - common - 8.0.24-1. El8. X86_64 installed [root @ 2 hadoop] # RPM -ivh mysql-community-client-plugins-8.0.24-1.el8.x86_64. RPM -ivh mysql-community-client-plugins-8.0.24-1.el8.x86_64. RPM Header V3 DSA/SHA1 Signature, key ID 5072E1F5: NOKEY Verifying... ################################# [100%] Preparing... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%] is upgrading/installing... 1:mysql-community-client-plugins-8.################################# [100%] [root@node2 hadoop]# rpm -ivh Mysql-community-libs-8.0.24-1.el8.x86_64. RPM: mysql-community-libs-8.0.24-1.el8.x86_64. RPM: Header V3 DSA/SHA1 Signature, key ID 5072E1F5: NOKEY Verifying... ################################# [100%] Preparing... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%] is upgrading/installing... 1: mysql - community - libs - 8.0.24-1. El8 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%] [root @ 2 hadoop] # RPM - the ivh Mysql-community-client-8.0.24-1.el8.x86_64. RPM: mysql-community-client-8.0.24-1.el8.x86_64. RPM: Header V3 DSA/SHA1 Signature, key ID 5072E1F5: NOKEY Verifying... ################################# [100%] Preparing... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%] is upgrading/installing... 1: mysql - community - the client - 8.0.24-1. E# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%] [root @ 2 hadoop] # RPM - the ivh Mysql-community-server-8.0.24-1.el8.x86_64. RPM: mysql-community-server-8.0.24-1.el8.x86_64. RPM: Header V3 DSA/SHA1 Signature, key ID 5072E1f5: NOKEY error: dependency detection failed: /usr/bin/perl is required by mysql-community-server-8.0.24-1.el8.x86_64. Net tools is required by mysql-community-server-8.0.24-1.el8.x86_64Copy the code

Perl and Net-Tools need to be installed first

3. Install perl

[root@node2 hadoop]# yum -y install perl Dependency resolution. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = warehouse size package architecture version = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = installation: perl x86_64 4:5. 26.3-419 el8 appstream 73 k install dependencies: DWZ x86_64 0.12-9.el8 appstream 109 K Ef-SRPm-Macros noarch 3-3.el8 Appstream 22 K GHC-SRPm-Macros noarch 1.4.2-7.el8 Appstream 9.3k go-srpm-macros noarch 2-17.el8 Appstream 13 K make x86_64 1:4.2.1-10.el8 baseos 498 K
## omit. Finished!Copy the code

4. Install.net – tools

[root@node2 hadoop]# yum -y install net-tools Dependency resolution. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = warehouse size package architecture version = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = installation: Net-tools x86_64 2.0-0.52.20160912 Git.el8 Baseos 322 K transaction summary = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 1 installation package download: 322 k installation size: 942 k download package: Net - tools - 2.0-0.52.20160912 git. El8. X86_64. RPM 827 kB/s | 322 kB 00:00 ------------------------------------------------------------------------------------------------------------------------ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- a total of 80 kB/s | 322 kB 00:04 running transactions check check successful transaction. Run transaction Test The transaction test succeeded. Running transaction preparation: 1/1 Installation: net-tools-2.0-0.52.20160912 Git.el8.x86_64 1/1 Running script: Net-tools-2.0-0.52.20160912 git.el8.x86_64 1/1 Net - tools - 2.0-0.52.20160912 git. El8. X86_64 finished!Copy the code

5. Install mysql – community – server

[root@node2 hadoop]# RPM -ivh mysql-community-server-8.0.24-1.el8.x86_64. RPM Mysql -community-server-8.0.24-1.el8.x86_64. RPM: header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Verifying... ################################# [100%] Preparing... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%] is upgrading/installing... 1: mysql - community - server - 8.0.24-1. E# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%] [/ usr/lib/tmpfiles. D/mysql. Conf: 23] Line References Path below Legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly.Copy the code

6. Check whether mysql is successfully installed

[root @ 2 hadoop] # RPM - qa | grep -i mysql mysql - community - libs - 8.0.24-1. El8. X86_64 Mysql - community - the client - plugins - 8.0.24-1. El8. X86_64 mysql - community - the client - 8.0.24-1. El8. X86_64 Mysql - community - server - 8.0.24-1. El8. X86_64 mysql - community - common - 8.0.24-1. El8. X86_64Copy the code
[root@node2 hadoop]# mysqladmin --version mysqladmin Ver 8.0.24 for Linux on x86_64 (MySQL Community server-gpl)Copy the code

7. Initialize mysql

[root@node2 hadoop]# mysqld --initialize // create data file directory and mysql system databaseCopy the code

8. Start the mysql service

[root@node2 hadoop]# systemctl start mysqld.service
Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
Copy the code

Wrong again -_ – | |

The solution

This is because the /var/lib/mysql directory has insufficient permissions

[root@node2 hadoop]# CD /var/lib/mysql [root@node2 mysql]# ll total usage 167348-rw-r -----. 1 root root 56 June 19 20:00 auto-.cnf -rw-r-----. 1 mysql mysql 0 June 19 20:01 binlog.index -rw-------. 1 root root 1676 June 19 20:00 ca-key.pem -rw-r--r-- Pem -rw-r--r-- 1 root root 1112 June 19 20:00 ca.pem -rw-r--r-- 1 root root 1676 Pem -rw-r-----. 1 root root 196608 June 19 20:00 '#ib_16384_0.dblwr' -rw-r----- 8585216 June 19 20:00 '#ib_16384_1.dblwr' -rw-r-----. 1 root root 3595 June 19 20:00 IB_buffer_pool -rw-r-----. 1 root root 12582912 June 19 20:00 ibData1-rw-r -----. 1 root root 50331648 June 19 20:00 ib_logfile0 -rw-r-----. 1 root root 50331648 6月 19 20:00 ib_logfile1 drwxr-x--. 2 root root 6月 19 20:00 '#innodb_temp' drwxr-x-- 1 root root 15728640 June 19 20:00 mysql. Ibd drwxr-x--. 2 root root 8192 June 19 20:00 Performance_schema 1 root root 1676 June 19 20:00 private_key.pem -rw-r--r--. 1 root root 452 June 19 20:00 public_key.pem -rw-r--r--. 1 root root 1112 June 19 20:00 server-cert.pem -rw-------. 1 root root 1676 June 19 20:00 server-key.pem 1 root root 16777216 June 19 20:00 undo_001 -rw-r-----. 1 root root 16777216 June 19 20:00 undo_002Copy the code

Change permissions and start mysql

[root@node2 ~]# setenforce 0 [root@node2 ~]# chown -R mysql:mysql /var/lib/mysql [root@node2 ~]# chmod -R 777 /var/lib/mysql [root@node2 ~]# systemctl start mysqld.service [root@node2 ~]# ps -ef |grep mysql mysql 26627 1 4 23:57 ?  00:00:00 /usr/sbin/mysqld root 26671 10438 0 23:57 pts/0 00:00:00 grep --color=auto mysql [root@node2 ~]# cd /var/lib/mysql [root@node2 mysql]# ll total usage 190916-rw-r -----. 1 mysql mysql 56 June 19 23:57 auto-cnf-rw-r -----. 1 mysql Mysql 156 June 19 23:57 binlog.000001 -rw-r-----. 1 mysql mysql 16 June 19 23:57 binlog.index -rwxrwxrwx. 1 mysql mysql 1680 June 19 23:50 ca - key. Pem - RWXRWXRWX. 1 mysql mysql June 19 23:50 ca 1112. Pem - RWXRWXRWX. 1 mysql mysql 1112 23:50 June 19 Client-cert. pem-rwxrwxrwx. 1 mysql mysql 1676 June 19 23:50 client-key.pem-rwxrwxrwx. 1 Mysql mysql 196608 June 19 23:57 '#ib_16384_0.dblwr' -rwxrwxrwx. 1 mysql mysql 8585216 1 mysql mysql 12582912 June 19 23:57 ibData1-rwxrwxrwx. 1 mysql mysql 50331648 June 19 1 mysql mysql 50331648 June 19 23:50 ib_logfile1-rwxrwxrwx. 1 mysql mysql 12582912 June 19 23:50 ib_logfile1-rwxrwx 2 mysql mysql 187 June 19 23:57 '#innodb_temp' DRWXRWXRWX. 2 mysql mysql 143 June 19 23:50 mysql -rwxrwx. 1 mysql mysql 27262976 June 19 23:57 mysql.ibd SRWXRWXRWX. 1 mysql mysql 0 June 19 23:57 mysql.sock-rw -------. 1 mysql mysql 6 June 19 23:57 mysql-sock. lock DRWXRWXRWX. 2 mysql mysql 8192 June 19 23:50 Performance_schema-rwxrwxrwx Mysql 1676 June 19 23:50 private_key.pem-rwxrwxrwx. 1 mysql 452 June 19 23:50 public_key.pem-rwxrwxrwx. 1 Mysql 1112 June 19 23:50 server-key.pem -rwxrwxrwx. 1 mysql 1680 June 19 23:50 server-key.pem DRWXRWXRWX. 2 Mysql 28 June 19 23:50 sys-rwxrwxrwx. 1 mysql 16777216 June 19 23:57 undo_001-rwxrwxrwx 16777216 June 19 23:57 undo_002 [root@node2 mysql]#Copy the code

Matters needing attention

  1. [InnoDB] Operating system error 13 in a file operation. Of this problem
  2. Directory permissions must be set to 777. Setting only 755 will also fail

Successfully solved

[root@node2 ~]# systemctl start mysqld.service
[root@node2 ~]# 
Copy the code

9. Verify

[root@node2 ~]# ps -ef |grep mysql mysql 26627 1 4 23:57 ? 00:00:00 /usr/sbin/mysqld root 26671 10438 0 23:57 pts/0 00:00:00 grep --color=auto mysql [root@node2 ~]# systemctl The status mysqld. Service low mysqld. Service - MySQL Server the Loaded: the Loaded (/ usr/lib/systemd/system/mysqld. Service; enabled; vendor preset: disabled) Active: active (running) since Sat 2021-06-19 23:57:02 CST; 11min ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 26603 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 26627 (mysqld) Status: "Server is operational" Tasks: 37 (LIMIT: 17656) Memory: 340.4m CGroup: / system. Slice/mysqld. Service └ ─ 26627 / usr/sbin/mysqld June 19 23:57:01 2 systemd [1] : Starting MySQL Server... June 19 23:57:02 Node2 systemd[1]: Started MySQL Server.Copy the code

10. Initialize the randomly generated password

/ root @ 2 ~ # cat/var/log/mysqld log | grep password 2021-06-19 T15: they. The 842799 z 6 [Note] [MY - 010454] (Server) A temporary password is generated for root@localhost: k6#gu=! gdJggCopy the code

11. Security Settings

[root@node2 ~]# mysql_secure_installation

Securing the MySQL server deployment.

#Enter the password you saw in step 10
Enter password for user root: 

#To reset your password
The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password: 

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

#Password strength: select 2 for production or 0 for personal testing
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Using existing password for root.

Estimated strength of the password: 100 

#After confirming the strength of the password, you have to re-enter the passwordChange the password for root ? ((Press y|Y for Yes, any other key for No) : y New password: Re-enter new password: Estimated strength of the password: 100 Do you wish to continue with the password provided? (Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.
#Whether to delete anonymous users
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

#Do not log in to the root server remotely
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

#Deleting a test database
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

#Reload the permission table
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 
[root@node2 ~]# 
Copy the code

12. Mysql login

#Use the new password to log in[root@node2 ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 Server version: 8.0.24 MySQL Community server-gPL Copyright (c) 2000, 2021, Oracle and/or its affiliates. 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> show databases;+--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + 4 rows in the set (0.00 SEC)Copy the code

Cent OS 8 installed MySQL 8 on Cent OS 8