1. Environmental preparation
Check when the Linux operating system version is CentOS release 6.10
[root@ufo130 ~]# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.10 (Final)
Release: 6.10
Codename: Final
2. Download the installation package
Download URL
https://dev.mysql.com/downloads/mysql/ to
download the mysql installation package of the corresponding operating system.
There are multiple packages to choose from. Generally, you can choose to download the client and server. (You will be prompted to log in to the oracle official website account, If not, you can register one)
3. Perform the installation
Switch to the root user and upload the installation package to the / opt directory
[root@ufo130 opt]# ll
-rw-r--r-- 1 root root 49219800 Apr 13 20:36 mysql-community-client-8.0.19-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 744268 Apr 13 22:51 mysql-community-common-8.0.19-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 8205352 Apr 13 22:52 mysql-community-devel-8.0.19-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 4798368 Apr 13 22:52 mysql-community-libs-8.0.19-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 1775392 Apr 13 22:52 mysql-community-libs-compat-8.0.19-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 545353864 Apr 13 22:10 mysql-community-server-8.0.19-1.el6.x86_64.rpm
Uninstall the previous mysql installation package (if you have installed the mysql service before, please refer to step 7)
[root@ufo130 opt]# rpm -qa|grep -i mysql
Execute the following installation commands in order
[root@ufo130 opt]# rpm -ivh mysql-community-common-8.0.19-1.el6.x86_64.rpm
[root@ufo130 opt]# rpm -ivh mysql-community-libs-8.0.19-1.el6.x86_64.rpm
[root@ufo130 opt]# rpm -ivh mysql-community-libs-compat-8.0.19-1.el6.x86_64.rpm
[root@ufo130 opt]# rpm -ivh mysql-community-devel-8.0.19-1.el6.x86_64.rpm
[root@ufo130 opt]# rpm -ivh mysql-community-client-8.0.19-1.el6.x86_64.rpm
[root@ufo130 opt]# rpm -ivh mysql-community-server-8.0.19-1.el6.x86_64.rpm
Check the installed mysql package
[root@ufo130 opt]# rpm -qa|grep -i mysql
mysql-community-libs-compat-8.0.19-1.el6.x86_64
mysql-community-server-8.0.19-1.el6.x86_64
mysql-community-libs-8.0.19-1.el6.x86_64
mysql-community-common-8.0.19-1.el6.x86_64
mysql-community-devel-8.0.19-1.el6.x86_64
mysql-community-client-8.0.19-1.el6.x86_64
4. Start or shut down the service
Start the mysql service and close the mysql service (the first time you start the service, the built-in /etc/my.cnf configuration file will be enabled, and you can configure more detailed parameters if you need to)
[root@ufo130 opt]# service mysqld start
初始化 MySQL 数据库: [确定]
正在启动 mysqld: [确定]
[root@ufo130 opt]# service mysqld stop
停止 mysqld: [确定]
5. Login settings
After installing the mysql service, the system will generate a temporary password that can be used for the first login
[root@ufo130 mysql]# grep 'temporary password' /var/log/mysqld.log|awk '{print $NF}'
YjR&%Oojo4g_
Temporary login, modify the root password, refresh the permission table (the modified password must meet the password policy: letter case, numbers and special characters, the length is not less than 8)
[root@ufo130 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.19
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>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Ufo_123456';
Query OK, 0 rows affected (0.09 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
Restart to take effect, verify login (successful login)
[root@ufo130 mysql]# service mysqld restart
停止 mysqld: [确定]
正在启动 mysqld: [确定]
[root@ufo130 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.19 MySQL Community Server - GPL
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>
6. File layout
Common file layout
/ usr / bin (client programs and scripts)
/ usr / sbin (mysqld server)
/ var / lib / mysql (log files and databases)
/ usr / share / doc / packages (documents)
/ usr / include / mysql (including header files)
/ usr / lib / mysql (library files)
/ usr / share / mysql * (error messages and character set files)
/ usr / share / sql-bench (benchmark program)
7. Perform uninstall
Uninstall in the reverse order of installation (note that the package name is not the full name of the package)
[root@ufo130 opt]# service mysqld stop
停止 mysqld: [确定]
[root@ufo130 opt]# rpm -e mysql-community-server
[root@ufo130 opt]# rpm -e mysql-community-client
[root@ufo130 opt]# rpm -e mysql-community-devel
[root@ufo130 opt]# rpm -e mysql-community-libs-compat
[root@ufo130 opt]# rpm -e mysql-community-libs
[root@ufo130 opt]# rpm -e mysql-community-common
[root@ufo130 opt]# rpm -qa|grep -i mysql
8. Summary
Advantages: simple installation, suitable for beginners.
Disadvantages: The installation path is not flexible, the default path cannot be modified, and one server can only install one mysql service. Especially when the amount of data is large, the default path is not convenient.