Detailed steps to install MySQL 5.7 via YUM on CentOS7

Detailed steps to install MySQL 5.7 via YUM on CentOS7

1. Go to the location where you want to store the installation package

cd /home/lnmp

2. Check whether the MySQL service has been installed in the system. There are two ways:

rpm -qa | grep mysql
yum list installed | grep mysql

3. If already installed, remove MySQL and its dependent packages:

yum -y remove mysql-libs.x86_64

4. Download the YUM source of mysql57-community-release-el7-8.noarch.rpm:

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

5. Install mysql57-community-release-el7-8.noarch.rpm:

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

After installation, you will get the following two packages:

mysql-community.repo
mysql-community-source.repo

6. Install MySQL. If prompted, press Y all the way to the end

yum install mysql-server

After the installation is complete, run mysql, and a random password will be automatically generated in the /var/log/mysqld.log file. We need to obtain this random password first to log in to the MySQL server:

service mysqld start
grep "password" /var/log/mysqld.log

The following content will be returned. The string at the end is the password. Copy it:

A temporary password is generated for root@localhost: hilX0U!9i3_6

7. Log in to the MySQL server and update the password for user root:

Note: Since MySQL 5.7 uses the password strength verification plug-in validate_password, we need to set a password with a certain strength;

mysql -u root -p
hilX0U!9i3_6

Then change your password

SET PASSWORD = PASSWORD('your new password');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
flush privileges;

Set user root to be accessible from any IP:

grant all privileges on *.* to root@"%" identified by "new password";

Set user root to be accessible locally:

grant all privileges on *.* to root@"localhost" identified by "new password";

Refresh permissions to make them effective:

flush privileges;

OK, enter exit and log in again with the new password!

Note: If you still cannot connect using the remote tool, try using the iptables -F command to clear the rules in the firewall chain.

8.MySQL control commands: start, stop, restart, check status

service mysqld start
service mysqld stop
service mysqld restart
service mysqld status

systemctl start mysqld
service mysqld stop
service mysqld restart
systemctl status mysqld

9. Set MySQL character set to UTF-8:

Open the my.cnf file in the /etc directory (this file is the main configuration file of MySQL):

vim /etc/my.cnf

Add the following code before [mysqld]:

[client] default-character-set=utf8

Add the following code after [mysqld]:

character_set_server=utf8

Log in to mysql again and check the character set. If 6 utf8 characters are OK,

show variables like '%character%';

10. Check the character set of the specified data table in the specified database, such as checking the character set of the servers table in the MySQL database:

show table status from mysql like '%servers%';

View the character sets of all columns of a specified table in a specified database, such as viewing the character sets of all columns of the servers table in the MySQL database:

show full columns from servers;

11. If you forget your password, you can reset it as follows:

service mysqld stop
mysqld_safe --user=root --skip-grant-tables --skip-networking &
mysql -u root

After entering MySQL

use mysql;
update user set password=password("new_password") where user="root"; 
flush privileges;

12. Storage directory of some files

Configuration Files

vim /etc/my.cnf

Directory where database files are stored

cd /var/lib/mysql

Logging Files

vim /var/log/ mysqld.log

Service startup script

/usr/lib/systemd/system/mysqld.service

Socket file

/var/run/mysqld/mysqld.pid

13.MySQL uses the TCP/IP protocol to transmit data. The default port number is 3306. We can view it through the following command:

netstat -anp

Summarize

The above is the detailed steps for installing MySQL5.7 on CentOS7 through YUM introduced by the editor. I hope it will be helpful to everyone!

You may also be interested in:
  • MySQL 5.7.30 Installation and Upgrade Issues Detailed Tutorial
  • Detailed graphic and text tutorial on downloading, installing and configuring mysql-5.7.28 under Windows
  • Tutorial on installing MySQL 5.7.28 on CentOS 6.2 (mysql notes)
  • MySQL 5.7.27 installation and configuration method graphic tutorial
  • MySQL5.7.27-winx64 version win10 download and installation tutorial diagram
  • MySQL 5.7 installation and configuration tutorial under CentOS7 64 bit
  • MySQL 5.7.33 installation process detailed illustration

<<:  Native JS realizes compound motion of various motions

>>:  Summary of discussion on nginx cookie validity period

Recommend

How to build DockerHub yourself

The Docker Hub we used earlier is provided by Doc...

Introduction to the use of em in elastic layout in CSS3: How many pixels is 1em?

I have been using CSS for a long time, but I have...

How to implement mysql database backup in golang

background Navicat is the best MySQL visualizatio...

Implementing Binary Search Tree in JavaScript

The search binary tree implementation in JavaScri...

Detailed explanation of monitoring NVIDIA GPU usage under Linux

When using TensorFlow for deep learning, insuffic...

react-diagram serialization Json interpretation case analysis

The goal of this document is to explain the Json ...

canvas.toDataURL image/png error handling method recommendation

Problem background: There is a requirement to tak...

Docker container log analysis

View container logs First, use docker run -it --r...

Using Docker to create static website applications (multiple ways)

There are many servers that can host static websi...

5 VueUse libraries that can speed up development (summary)

Table of contents What utilities does VueUse have...

Detailed example of SpringBoot+nginx to achieve resource upload function

Recently, I have been learning to use nginx to pl...

Detailed explanation of the basic implementation principle of MySQL DISTINCT

Preface DISTINCT is actually very similar to the ...

Summary of several common methods of JavaScript arrays

Table of contents 1. Introduction 2. filter() 3. ...

Installation and configuration of MySQL 5.7.17 free installation version

MYSQL version: MySQL Community Server 5.7.17, ins...