Linux8 (CentOS 7) system installation MySQL8 | MySQL installation tutorial

Linux8 (CentOS 7) system installation MySQL8 | MySQL installation tutorial

CentOS 7 version removed the MySQL database software from the default program list and replaced it with MariaDB. The MariaDB database management system is a branch of MySQL, which is mainly maintained by the open source community and is licensed under the GPL.

This chapter of the MySQL installation tutorial under the Linux system. All installation operations are performed in the CentOS 7 system.

View system version

Use the cat /etc/redhat-releasecommand to query the system version, as shown below

[root@LiaNg ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core)
Clean up the mariadb database in CentOS 7

Run the following command to clean up the mariadb database that comes with CentOS 7:
rpm -qa |grep mariadb |xargs yum remove -y

No matter what installation method you choose, to prevent conflicts, it is recommended to manually clean mariadb before installing MySQL ** _

Download MySQL related installation packages

Click Download MySQL into the MySQL download page, download the version according to system.

  • Windows :
    CentOS 7 system version can be directly clicked to download mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar,
    download and upload to server
  • Linux :
    download using wget command, download address:
    https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar

Install MySQL

  1. Enter the mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar file storage directory
  2. Execute the command: tar -xvf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar -C /opt/software/mysql(Unzip the compressed package to / opt / software / mysql directory)
  3. Enter the decompression directory:cd /opt/software/mysql
  4. 包含 8 个 rpm 包,如下所示:
    mysql-community-client-8.0.18-1.el7.x86_64.rpm
    mysql-community-common-8.0.18-1.el7.x86_64.rpm
    mysql-community-devel-8.0.18-1.el7.x86_64.rpm
    mysql-community-embedded-compat-8.0.18-1.el7.x86_64.rpm
    mysql-community-libs-8.0.18-1.el7.x86_64.rpm
    mysql-community-libs-compat-8.0.18-1.el7.x86_64.rpm
    mysql-community-server-8.0.18-1.el7.x86_64.rpm
    mysql-community-test-8.0.18-1.el7.x86_64.rpm
  5. Install each package separately (please install the common, libs, and libs-compat packages in order)
rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-test-8.0.18-1.el7.x86_64.rpm
  1. Initialize MySQL:mysqld --initialize
  2. Adjust the attribution of the data directory:chown mysql:mysql /var/lib/mysql -R

Default data directory: / var / lib / mysql, you can change the datadir parameter in /etc/my.conf

  1. Start MySQL:systemctl start mysqld.service
  2. View MySQL:systemctl status mysqld.service
[root@LiaNg mysql]# systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-10-24 18:39:12 CST; 8s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 30356 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 30388 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─30388 /usr/sbin/mysqld
Query initial password

At this point, MySQL has started to run normally, but to enter MySQL, you must first find out the password of the root user at this time, you can find the password in the log file by the following command:

  1. After MySQL installation is complete, the initial password is stored in /var/log/mysqld.loga file
  2. Excuting an order:grep password /var/log/mysqld.log
[root@v2svnw mysql]# grep password /var/log/mysqld.log
2019-10-24T10:38:25.465382Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: *7C,#tQ6dc1f
  1. As shown above: *7C,#tQ6dc1fMySQL initial password
Log in to MySQL to verify success
[root@v2svnw ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 8.0.18

Copyright (c) 2000, 2019, 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> 

At this point, MySQL 8 has been successfully installed.

Linux start MySQL service

systemctl start mysqld.service # Start mysqld
systemctl stop mysqld.service # Stop mysqld
systemctl restart mysqld.service # Restart mysqld
systemctl enable mysqld.service # Set boot start
systemctl status mysqld.service # View status

Failed dependencies

  1. error: Failed dependencies: libnuma.so.1()(64bit) is needed by ……
    yum install numactl -y
  2. error: Failed dependencies: pkgconfig(openssl) is needed by ……
    yum install openssl-devel -y
  3. error: Failed dependencies: perl(Data::Dumper) is needed by ……
    yum install autoconf -y
  4. error: Failed dependencies: perl(JSON) is needed by ……
    yum install perl-JSON -y
Published 7 original articles · Like 3 · Visits 320

Guess you like

Origin blog.csdn.net/sl285720967/article/details/103005630