CentOS7 installs and remotely connects to MySQL8.0.33

I. Introduction

When learning the advanced chapter of MySQL, you need to install MySQL on CentOS, and then connect to it remotely, so I took two days to read 95% of the Linux chapter delivered by St. Regis

This article is an excerpt of the part about installing MySQL in the study notes, as a reference and as a share

insert image description here

2. Install MySQL

First check whether the MySQL database has been installed in the current system. If it has been installed, the installation will fail. At the same time, the mariadb that comes with CentOS7 will conflict with the MySQL database.

rpm -qa: Query all software installed in the current system

rpm -qa|grep mysql: Query whether there is mysql in the software name installed in the current system

rpm -qa|grep mariadb: Query whether there is mariadb in the software name installed in the current system

RPM (Red-Hat Package Manager) is a package manager, a tool used by Red Hat Linux to manage and install software

【Practice diagram】

image-20230722214231594

Uninstall conflicting software installed

rpm -e --nodeps 软件名称: Uninstall the software

rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64

【Practice diagram】

image-20230722214708954

The preparatory work is completed here, and the next step is the formal installation

first step

Go to the official website to download the Linux version of MySQL, here select the same version of MySQL as the local machine

image-20230722215310980

second step

Use the upload tool that comes with FinalShell to upload the MySQL compressed package to Linux

image-20230722215829742

third step

Move the mysql compressed package to the created directory

image-20230722220105983

the fourth step

Decompress the mysql compressed package

image-20230722220429858

the fifth step

Install the rpm package

rpm -ivh *.rpm --nodeps --force

image-20230722221603126

step six

start mysql

systemctl status mysqld: View mysql service status

systemctl start mysqld: start the mysql service

image-20230722222026605

Description: You can set the mysql service to start at boot time to avoid starting mysql every time you boot

systemctl enable mysqld: Start the mysql service on boot

netstat -tunlp: View started services

netstat -tunlp|grep mysql

ps -ef|grep mysql: View the mysql process

Note: net-tools needs to be installed

image-20230722222408872

image-20230722222614009

3. Log in to the MySQL database

View Temporary Password

cat /var/log/mysqld.log: view file content

cat /var/log/mysqld.log|grep password: View the line information containing password in the file content

image-20230722223333466

image-20230722223624852

Modify temporary password

Modify the password first and then set the verification rules and password length

alter user 'root'@'localhost' identified with mysql_native_password by 'Root_12root';: The modified password must contain numbers, uppercase and lowercase letters, and special characters, and the length must be more than 8

set global validate_password.policy=0;: Set the password with a low security level, which is convenient for password modification

set global validate_password.length=4;: Set the minimum number of digits in the password length

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';: Change the password to a simple password

image-20230722225828959

image-20230722225859441

Turn on access

Create a user first, assign user permissions to the user, and then refresh permissions

CREATE USER 'root'@'%' IDENTIFIED BY '123456';

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;

Note: CREATE USER 'root'@'%' IDENTIFIED BY '123456'; The middle '123456'is the access password of the remote connection

image-20230723101038751

Open port 3306: firewall-cmd --zone=public --add-port=3306/tcp --permanent, firewall-cmd --reload,firewall-cmd --zone=public --list-ports

image-20230722231453261

Use navicat to test remote connection to mysql on Linux, or use DataGrip to test remote connection to mysql on Linux

image-20230723101742200

image-20230723101801312

Guess you like

Origin blog.csdn.net/lion_no_back/article/details/131877005