Centos7 Installing Mysql8 Tutorial

  • 2021-08-21 21:56:28
  • OfStack

New features of Mysql8:

Mysql jumps directly from 5. x to 8. x, and I personally see it this way:

MySQL 5.5 - > MySQL 5
MySQL 5.6 - > MySQL 6
MySQL 5.7 - > MySQL 7
MySQL 8.0 - > MySQL 8

Of course, it is also possible that Mysql6 and 7 are dystocia-_-. Since it was acquired by Oracle, its vitality is still there. mysql8 has the following new features:

MySQL Document Storage Default utf8mb4 encoding JSON Enhancement CTEs (Translator's Note: Common Table Expresssions Common Table Expression) Window function Descending index Better Optimizer Consumption Model MySQL Server Components GIS (Translator's Note: Geographic Information System Geographic Information System) Upgrade NO WAIT and SKIP\ LOCKED options for InnoDB engine

Centos7 Mysql8 Installation steps:

1. Set the mysql source

First, you need to enable the MySQL yum repository on the system provided by MySQL. Execute one of the following commands according to your operating system version, where we select the source of CentOS 7/RHEL 7


### In CentOS 7 / RHEL 7 On the system ### 
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm

### In CentOS 7 / RHEL 6 On the system ### 
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el6-3.noarch.rpm

### In Fedora 30 On the system ### 
rpm -Uvh https://repo.mysql.com/mysql80-community-release-fc30-1.noarch.rpm

### In Fedora 29 On the system ### 
rpm -Uvh https://repo.mysql.com/mysql80-community-release-fc29-2.noarch.rpm

### In Fedora 28 On the system ### 
rpm -Uvh https://repo.mysql.com/mysql80-community-release-fc28-2.noarch.rpm

2. Install MySQL Community Server

The MySQL yum repository contains multiple repository configurations for multiple MySQL versions. Therefore, first disable all repositories in the mysql repo file


sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo

Enable centos mysql 8 version


## CentOS & RedHat  Version 
yum --enablerepo=mysql80-community install mysql-community-server
## Fedora Systems  Version 
dnf --enablerepo=mysql80-community install mysql-community-server

3. Start the MySQL service


service mysqld start

Using Systemd


systemctl start mysqld.service

4. Find the MySQL root password

After installing MySQL 8.0, a temporary password is created for the MySQL root user. You can find the generated temporary password in the log file. Password file location:/var/log/mysqld. log


grep "A temporary password" /var/log/mysqld.log

5. Reset the root password

After the first installation of MySQL, execute the mysql_secure_installation command to protect the MySQL server, including the password reset step


mysql_secure_installation

Enter password for user root:

The existing password for the user account root has expired. Please set a new password.

New password:
Re-enter new password:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

6. The mysql service adds startup items and starts the mysql process


### Using Systemd
systemctl enable mysqld.service
systemctl restart mysqld.service

7. Open Port 3306

If the server has a firewall on, remember to open port 3306


systemctl enable iptables
systemctl start iptables
vim /etc/sysconfig/iptables
## Add to the rule 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
## Restart the firewall 
systemctl enable iptables.service
systemctl start iptables.service

If you use Tencent Cloud's server, you must remember to open the port in the security group

Attached is the common command of mysql:

Login to mysql


sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo
0

Start mysql


sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo
1

End mysql


sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo
2

Restart mysql


systemctl restart mysqld.service

Startup and self-startup


sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo
4

These are the details of the Centos7 installation Mysql8 tutorial. For more information about Centos7 installation Mysql8, please pay attention to other related articles on this site!


Related articles: