How to install MySql in CentOS 8 and allow remote connections

How to install MySql in CentOS 8 and allow remote connections

Download and install. First check whether there is MySQL or MariaDB in the system. If so, uninstall it first.

rpm -qa | grep mysql
rpm -qa | grep mariadb

As shown in the figure, there is mariaDB data in my system.

Execute uninstallation. If there is MySQL, the uninstallation method is the same.

remove mariadb-libs-5.5.52-1.el7.x86_64

To install the dependent environment, we directly use yum to install it and execute it in sequence

yum install -y perl.x86_64
yum install -y libaio.x86_64
yum install -y net-tools.x86_64
yum install -y libtinfo*
yum install -y libncurses*

Download the domestic MySQL installation package (the reason for using the domestic one is that it downloads faster. The mirror resource of Tsinghua University is used below)

wget -P /tmp http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-common-5.7.31-1.el7.x86_64.rpm
wget -P /tmp http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-libs-5.7.31-1.el7.x86_64.rpm
wget -P /tmp http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-client-5.7.31-1.el7.x86_64.rpm
wget -P /tmp http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-community-server-5.7.31-1.el7.x86_64.rpm

Then install mysql dependencies in order, execute them one by one

rpm -ivh mysql-community-common-5.7.31-1.el7.x86_64.rpm 
rpm -ivh mysql-community-libs-5.7.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.31-1.el7.x86_64.rpm

Restart the mysql service

systemctl restart mysqld.service

Check the mysql service status

systemctl status mysqld.service

Check the default temporary password. My password is: >dgp,9q&?ikW

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

Test Login

mysql -u root -p

Then enter the password and log in successfully.

Change the password and enable remote connection

Since the new version of MySQL has upgraded the password security policy, if you have been using the default password,

Many functions are restricted, including modifying security policies and enabling remote connections;

So you still need to change your password first. The password must contain a combination of uppercase and lowercase letters, numbers, and special characters. Log in first

mysql -u root -p

Then change the password

ALTER USER 'root'@'localhost' IDENTIFIED BY '~1QAZxsw2'

Modify to allow remote connections

use mysql;
update user set Host = '%' where Host = 'localhost' and User='root';
flush privileges;

Open port 3306 Open port 3306

firewall-cmd --zone=public --add-port=3306/tcp --permanent

Restart the firewall

firewall-cmd --reload

Check the firewall status to show success, which means it is successfully enabled.

systemctl status firewalld

Check the status of the specified port and it will show success, which means the port is successfully opened.

firewall-cmd --query-port=6379/tcp

Then use the database connection tool to connect successfully;

This is the end of this article about installing MySql on CentOS 8 and setting up to allow remote connections. For more information about setting up MySql on CentOS 8 to allow remote connections, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solve the problem of error 10038 when connecting to MySQL remotely in Navicat
  • Detailed explanation of Navicat's slow remote connection to MySQL
  • Tutorial on installing MySQL with Docker and implementing remote connection
  • Solution to the problem that Navicat cannot remotely connect to MySql server
  • How to solve the 10060 unknow error when Navicat remotely connects to MySQL
  • Docker deploys mysql to achieve remote connection sample code
  • Navicat remote connection to MySQL implementation steps analysis
  • Tutorial on installing MySql5.7 in CentOS7.2 and enabling remote connection authorization
  • How to authorize remote connections in MySQL in Linux
  • How to enable MySQL remote connection

<<:  Detailed explanation of the service problem reported by Ubuntu 20.04 using Xshell through SSH connection

>>:  WeChat applet to determine whether the mobile phone number is legal example code

Recommend

MySQL complete collapse query regular matching detailed explanation

Overview In the previous chapter, we learned abou...

Nginx domain name SSL certificate configuration (website http upgraded to https)

Preface HTTP and HTTPS In our daily life, common ...

The w3c organization gives style recommendations for html4

This is the style recommendation given by the W3C ...

Introduction to JavaScript Number and Math Objects

Table of contents 1. Number in JavaScript 2. Math...

Detailed explanation of deploying MySQL using Docker (data persistence)

This article briefly describes how to use Docker ...

Implementation of mysql split function separated by commas

1: Define a stored procedure to separate strings ...

Implementation of waterfall layout + dynamic rendering

Table of contents Typical waterfall website Water...

MySQL 8.0.21.0 Community Edition Installation Tutorial (Detailed Illustrations)

1. Download MySQL Log in to the MySQL official we...

W3C Tutorial (5): W3C XML Activities

XML is designed to describe, store, transmit and ...

Application scenarios and design methods of MySQL table and database sharding

Many friends have asked in forums and message are...

Simple use of Vue vee-validate plug-in

Table of contents 1. Installation 2. Import 3. De...

MySQL 5.6.23 Installation and Configuration Environment Variables Tutorial

This article shares the installation and configur...

Installation and use of Apache stress testing tools

1. Download Go to the Apache official website htt...