This is the 26th day of my participation in the August More Text Challenge. For the Nuggets’ August challenge,

This tutorial teaches you how to install the MySQL database on Linux, using CentOS 8 as an example.

Before, I bought aliyun server Centos7, install mysql, hereby record, convenient for myself to find and use in the future

1. Download and install the official MySQL Yum Repository

wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
Copy the code

Yum Repository: Yum Repository: Yum Repository: Yum Repository: Yum Repository: Yum Repository: Yum Repository

2. Install the REPO:

rpm -ivh mysql80-community-release-el7-1.noarch.rpm
Copy the code

Repo mysql-community-source.repo two repo files are generated in the /etc/ym.repos. d/ directory

Then start installing MySQL server.

 yum install mysql-server
Copy the code

This step may take some time, and once the installation is complete, the previous Mariadb will be overwritten.

Mysql: /var/log/mysqld.log: /var/log/mysqld.log: /var/log/mysqld.log: /var/log/mysqld.log: /var/log/mysqld.log: /var/log/mysqld.log

tail -200f  /var/log/mysqld.log
Copy the code

Blog.csdn.net/liurui50/ar…

2. Set the MySQL database

2.1. Set case insensitive

vim /etc/my.cnf
Copy the code

Under [mysqld], add the following

#Make MYSQL case-sensitive (1- insensitive, 0- sensitive)
lower_case_table_names=1
Copy the code

2.2. Start the MySQL

systemctl start mysqld.service 
Copy the code

2.3. Check the MySQL running status

systemctl status mysqld.service
Copy the code

2.4. Set a password

If you want to access MySQL, you need to find the password of user root. Run the following command to find the password in the log file:

grep "password" /var/log/mysqld.log
Copy the code

Enter database:

mysql -uroot -p
Copy the code

Enter the initial password just above

You can’t do anything at this point because MySQL must change the password by default to operate on the database:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
Copy the code

The new password is the root password that you set to the root password.

Make your password as complex as possible

2.5. Set remote access

At this time, remote access is not possible, such as Navicat cannot access

In the middle

2.5.1 Opening ports

(1) Open port 3306

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

(2) If the message “FirewallD is not running” is displayed, as shown below

(3) Run the systemctl status firewalld command to check the Firewalld status. The firewall is in dead state, that is, the firewall is disabled.

(4) Run systemctl start firewalld to start the firewall. If no prompt is displayed, the firewall is successfully started.

(5) Run systemctl status firewalld to check the status of Firewalld. If running is displayed, firewalld is enabled.

(6) If you want to disable firewall Settings, you can run the systemctl stop firewalld command to disable this function.

Firewall – CMD –permanent –zone=public –add-port=3306/ TCP

(8) Refresh

firewall-cmd --reload
Copy the code

2.5.2. Root Remote Access

When the firewall is enabled, Navicat access appears as shown below:

(1) Set the authentication mode. If you have not set an authentication mode, the default password encryption mode is caching_sha2_password.

client does not support  authentication protocol requested by server; consider upgrading MySQL client
Copy the code

/etc/my.cnf (vim /etc/my.cnf) : [mysqld] : [mysqld] : [mysqld] :

default_authentication_plugin=mysql_native_password
Copy the code

(2) Log in to the mysql command line: enter the password

mysql -u root -p
Copy the code

(3) Select mysql library after entering, user information is stored in the user table of this library

use mysql;
select host, user, authentication_string, plugin from user;
Copy the code

In the middle

As you can see, the user’s host is localhost, not %, so it cannot connect. (4) Authorize the root user to log in remotely

update user set host=The '%' where user = 'root';
flush privileges;
Copy the code

(5) Refresh permissions

flush privileges;
Copy the code

2.6 Alicloud Requires port 3306 to be enabled for setting security groups

Security groups – Configuration rules – You can add them quickly

At this point, the database is installed and configured. Such a detailed graphic tutorial, have you learned? Collect it and try it!

2.7 2059 Incorrect Solution

In the latest version of MySQL (version 8 or later), caching_sha2_password is used to encrypt user login accounts. Navicat does not support this method.

perform

show variables like 'default_authentication_plugin';
select host,user,plugin from mysql.user;

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'mima';
flush privileges;
Copy the code