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

Detailed Example of CSS3 box-shadow Property

CSS3 -- Adding shadows (using box shadows) CSS3 -...

js to implement verification code interference (dynamic)

This article example shares the specific code of ...

Detailed tutorial for installing mysql5.7.21 under Windows

This article shares the installation tutorial of ...

Our thoughts on the UI engineer career

I have been depressed for a long time, why? Some t...

vue-admin-template dynamic routing implementation example

Provide login and obtain user information data in...

How to solve the mysql ERROR 1045 (28000)-- Access denied for user problem

Problem description (the following discussion is ...

How to process blob data in MySQL

The specific code is as follows: package epoint.m...

JavaScript Interview: How to implement array flattening method

Table of contents 1 What is array flattening? 2 A...

Vue realizes the progress bar change effect

This article uses Vue to simply implement the cha...

Two ways to implement HTML page click download file

1. Use the <a> tag to complete <a href=&...

Implementation of Nginx configuration Https security authentication

1. The difference between Http and Https HTTP: It...

A solution to the abnormal exit of Tomcat caused by semaphore

I'm playing with big data recently. A friend ...

Implementation of CSS text shadow gradually blurring effect

text-shadow Add a shadow to the text. You can add...

Method of iframe adaptation in web responsive layout

Problem <br />In responsive layout, we shou...