Operating System Privilege Elevation (Twenty-Five) Database Privilege Elevation-Centos7 Installation of MySQL

Install MySQL on Centos7

We first need to install a Centos7 VMware in the virtual machine to install Centos7

MySQL installation

1. Download the wget command

yum -y install wget

Insert image description here

2. Download the mysql installation package online

wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

Insert image description here

3. Install MySQL

rpm -ivh mysql57-community-release-el7-8.noarch.rpm

Insert image description here

4. Install mysql service

First enter the cd /etc/yum.repos.d/ directory

cd /etc/yum.repos.d/

Insert image description here

Install the MySQL service (this process may be a bit slow)

yum -y install mysql-server

Insert image description here

If you encounter the following error situation

Insert image description here

Please execute the following command

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

Insert image description here

Then execute the following command again

yum -y install mysql-server

5. Start MySQL

systemctl start mysqld
查看进程:
ps -ef | grep mysql

Insert image description here

Modify MySQL temporary password

After MySQL is successfully installed, there will be a temporary password. We can use the grep command to view the temporary password. First log in to MySQL, and then change the MySQL password.

1. Obtain MySQL temporary password

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

Insert image description here

2. Use the temporary password to log in first

mysql -uroot -p

My temporary password is: jlHfYlWae0:>

Insert image description here

3. Change the password verification strength of MySQL to low risk

set global validate_password_policy=LOW;

Insert image description here

4. Modify the password length of MySQL

set global validate_password_length=5;

Insert image description here

5. Change the MySQL password to admin

ALTER USER 'root'@'localhost' IDENTIFIED BY 'admin'; 

Insert image description here

Allow remote access

1. First, turn off the Cenots firewall.

sudo systemctl disable firewalld

Insert image description here

2. Modify MySQL to allow anyone to connect

1) First log in to MySQL

mysql -uroot -padmin

Insert image description here

2) Switch to mysql data

use mysql;

3) View the user table

select Host,User from user;

Insert image description here

It was found that the root user is only allowed to log in to the localhost host.

4) Modify to allow access from any address

update user set Host='%' where User='root';

Insert image description here

5) Refresh permissions

flush privileges;

Insert image description here

3. Use Navicat connection tool to test

Insert image description here

Insert image description here

Guess you like

Origin blog.csdn.net/qq_64973687/article/details/133012226