CentOS 8 / RHEL 8 install mysql5.7 and 8.0

CentOS 8 / RHEL 8 uses yum tool to install mysql8.0 by default, but mysql8.0 occupies memory. It is not recommended for machines with low server configuration It is a good choice to install mysql8.0 and mysql5.7. The following describes how to install the mysql5.7 database under CentOS 8 / RHEL 8 system

One, install mysql-8.0

CentOS 8 / RHEL 8 default mysql database version is 8.0, you can download and install it directly with yum tool:

# Installation
yum install mysql-community-server

Two, install mysql-5.7

CentOS 8 / RHEL 8 yum warehouse does not have mysql5.7 version resources by default, you need to add it yourself

1. Add yum warehouse configuration file

# Edit the configuration file with vi, create a new one without this file
vi /etc/yum.repos.d/mysql-community.repo

Add the following configuration to the file:

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

But we can only use one release version of a sub-repository. When the sub-repository has many released versions, the yum tool will also use the latest version 8.0 for installation

We must check that the correct sub-repository has been enabled, use the following command to check, and view the output:

# Check output
yum repolist enabled | grep mysql

2. Disable the default mysql module

As long as the default module is not prohibited, we cannot use package resources from the yum repository. In order to disable the default module and make the yum repository visible, we can use the following command:

# Disability module
yum module disable mysql

3. Install mysql

After configuring the yum repository, you can now use the yum tool to install, the installation command is as follows:

# Installation
yum install mysql-community-server

4. Start mysql service

Start mysql

# start up
service mysqld start
# Or
systemctl start mysqld.service

View status

service mysqld status
# Or
systemctl status mysqld.service

5. Reset mysql password

When MySQL is installed for the first time, it will randomly generate a random temporary password for root. Let’s reset the root account password:

View temporary password:

grep'temporary password' /var/log/mysqld.log

Log in with a temporary password:

mysql -uroot -p

Reset password:

# Update root password
ALTER USER'root'@'localhost' IDENTIFIED BY'MyNewPass4!';

There is a problem, prompting that the security requirements are not met, the reason is that the password is short:

The solution is to lower the password level:

# Lower the password level
set global validate_password_policy=LOW;

Now you can log in with the new password, and the mysql installation is now complete

0

Leave a Reply

Your email address will not be published.