1. Download the MySQL installation packageOfficial website address: https://dev.mysql.com/downloads/mysql/ Download steps: Filter by operating system version Select archive installation package After downloading, upload and verify the installation package with md5 to see if it is consistent with the official value in the figure above to ensure that the installation package is not damaged during the transmission process [root@MyDB1 ~]# cd /usr/local/software/ [root@MyDB1 software]# md5sum mysql-8.0.22-el7-x86_64.tar.gz 52e312605f66aaaa0efcd272b9fc0a1f mysql-8.0.22-el7-x86_64.tar.gz Unzip the installation package [root@MyDB1 software]# tar -zxvf mysql-8.0.22-el7-x86_64.tar.gz [root@MyDB1 software]# ln -s mysql-8.0.22-el7-x86_64/ mysql #Create a link for easy operation 2. MySQL uninstall instructions
Note: Before uninstalling the old MySQL, be sure to back up your data. [root@MyDB1 ~]# rpm -qa|grep mysql #Check if mysql database is installed [root@MyDB1 ~]# rpm -qa|grep mysql|xargs rpm -e --nodeps #Uninstall mysql [root@MyDB1 software]# rpm -qa|grep mariadb-libs|xargs rpm -e --nodeps #Uninstall mariadb 3. Create users and groupsCreate new groups and users [root@MyDB1 ~]# groupadd -g 2000 mysql [root@MyDB1 ~]# useradd -u 2000 -g mysql -c "MySQL Server" -s /sbin/nologin mysql [root@MyDB1 ~]# cat /etc/group|grep mysql mysql:x:2000: [root@MyDB1 ~]# cat /etc/passwd|grep mysql mysql:x:2000:2000:MySQL software:/home/mysql:/sbin/nologin Note: If the group and user already exist, delete the system default group and user and create them again! Deleting Groups and Users [root@MyDB1 ~]# userdel mysql #Deleting a user will also delete the corresponding group Grant permissions to the mysql path [root@MyDB1 ~]# cd /usr/local/software/ [root@MyDB1 software]# chown -R mysql:mysql mysql* Directory structure before initialization Note: There is no data directory at this time MySQL initializationEdit the configuration file before initialization [root@MyDB1 ~]# vi /etc/my.cnf [root@MyDB1 ~]# cat /etc/my.cnf The content is as follows: (other configurations are based on actual needs) [mysqld] basedir = /usr/local/software/mysql datadir = /usr/local/software/mysql/data log_error = /usr/local/software/mysql/mysql-error.log port = 3306 socket = /usr/local/software/mysql/mysqld.sock pid_file = /usr/local/software/mysql/mysqld.pid character-set-server=utf8 lower_case_table_names=1 max_connections=1000 sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' [mysql] default-character-set=utf8 [client] default-character-set=utf8 Initialization starts [root@MyDB1 ~]# /usr/local/software/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/software/mysql --datadir=/usr/local/software/mysql/data During the initialization process, the output log file contains the temporary password of the root user Directory structure after initialization 5. Start MySQL serviceMethod 1——init.d: Start the service [root@MyDB1 ~]# cp /usr/local/software/mysql/support-files/mysql.server /etc/init.d/mysqld [root@MyDB1 ~]# /etc/init.d/mysqld start Authentication Service [root@MyDB1 ~]# ps -ef|grep mysql Explanation There are two processes in the figure, a main process and a daemon process. When MySQL stops unexpectedly, the daemon will automatically restart the MySQL service Demo [root@MyDB1 ~]# kill -9 75341 #Kill the process directly Method 2 - systemctl: Edit the startup configuration file [root@MyDB1 subsys]# vi /etc/systemd/system/mysqld.service The content is as follows: (Disadvantage: When killed, recovery cannot be started automatically) [Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html Documentation=https://www.freedesktop.org/software/systemd/man/systemd.unit.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql LimitNOFILE = 5000 ExecStart=/usr/local/software/mysql/bin/mysqld --defaults-file=/etc/my.cnf Start the service [root@MyDB1 ~]# systemctl start mysqld.service [root@MyDB1 ~]# systemctl status mysqld.service 6. Safety and efficiency optimizationLaunch permission restrictions [root@MyDB1 ~]# cd /usr/local/software/mysql/bin/ [root@MyDB1 bin]# chmod 700 mysqld mysqld_safe [root@MyDB1 bin]# ll mysqld mysqld_safe -rwx------. 1 mysql mysql 441010738 Sep 24 03:42 mysqld -rwx------. 1 mysql mysql 29157 Sep 24 03:18 mysqld_safe Note: Now only the root user can start and stop the MySQL service! The service starts with the system systemctl enable mysqld.service systemctl list-unit-files | grep mysql 7. Configure environment variables[root@MyDB1 ~]# vi /etc/profile The additional content is as follows: MYSQL_HOME=/usr/local/software/mysql export PATH=.:$PATH:$MYSQL_HOME/bin [root@MyDB1 ~]# source /etc/profile #Reload to take effect! 8. Modify the initial root passwordCreate a socket connection [root@MyDB1 ~]# ln -s /usr/local/software/mysql/mysqld.sock /tmp/mysql.sock Log in using a temporary password [root@MyDB1 ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.22 Copyright (c) 2000, 2020, 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> Note: When the temporary password contains special characters, the command line input may be ambiguous. At this point, just enter the password when interacting! Change root password mysql> alter user root@'localhost' identified by 'MyDB12@com'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) Note: The MySQL8 password must meet a certain complexity, otherwise it cannot be modified; after exiting the current session, restart the login to take effect! 9. Configure MySQL remote login
mysql> select user,host from mysql.user; +------------------+-----------+ | user | host | +------------------+-----------+ |mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +------------------+-----------+ 4 rows in set (0.00 sec) Problems encountered mysql> grant all privileges on *.* to root@'%' identified by 'MyDB12@com'; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'MyDB12@com'' at line 1 Note: This error is not a syntax error, because this version of MySQL does not support direct creation of users and granting of rights, but needs to be implemented separately Create a remote login user mysql> create user 'root'@'%' identified by 'MyDB12@com'; Query OK, 0 rows affected (0.01 sec) Empowerment mysql> grant all privileges on *.* to 'root'@'%'; Query OK, 0 rows affected (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) This is the end of this article about installing MySQL 8.0.22 on Redhat 7.3 (binary installation). For more information about installing MySQL 8.0.22 on Redhat 7.3, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: A brief discussion on VUE uni-app custom components
>>: CSS syntax for table borders
Table of contents Introduction Download and insta...
Table of contents 1. What is JSON 1.1 Array liter...
In response to the popularity of nodejs, we have ...
Preface: rm under Linux system is irreversible. T...
Note: sg11 Our company only supports self-install...
zabbix Zabbix ([`zæbiks]) is an enterprise-level ...
A simple record of the database startup problems ...
Table of contents Objectives for this period 1. F...
Table of contents Overview 1. Hook calling order ...
1. Vertical table and horizontal table Vertical t...
Preface I believe that everyone has had experienc...
The author recently encountered a performance bot...
In Black Duck's 2017 open source survey, 77% ...
This article shares the specific code of vue+vide...
One-click execution To install Python 3.8 in a vi...