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

react-beautiful-dnd implements component drag and drop function

Table of contents 1. Installation 2.APi 3. react-...

A complete tutorial on using axios encapsulation in vue

Preface Nowadays, in projects, the Axios library ...

Method example of safely getting deep objects of Object in Js

Table of contents Preface text parameter example ...

The difference between br and br/ in HTML

answer from stackflow: Simply <br> is suffic...

Implementing Binary Search Tree in JavaScript

The search binary tree implementation in JavaScri...

jQuery implements HTML element hiding and display

Let's imitate Taobao's function of displa...

Vue implements multi-column layout drag

This article shares the specific code of Vue to i...

Detailed explanation of the role of brackets in AngularJS

1. The role of brackets 1.1 Square brackets [ ] W...

Detailed introduction to the MySQL installation tutorial under Windows

Table of contents 1. Some concepts you need to un...

Vue must learn knowledge points: the use of forEach()

Preface In front-end development, we often encoun...

4 ways to optimize MySQL queries for millions of data

Table of contents 1. The reason why the limit is ...

XHTML Getting Started Tutorial: Form Tags

<br />Forms are an important channel for use...

When modifying a record in MySQL, the update operation field = field + string

In some scenarios, we need to modify our varchar ...