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

Implementation of navigation bar and drop-down menu in CSS

1. CSS Navigation Bar (1) Function of the navigat...

Deleting two images with the same id in docker

When I created a Docker container today, I accide...

Detailed explanation of how to enter and exit the Docker container

1 Start the Docker service First you need to know...

In-depth explanation of MySQL common index and unique index

Scenario 1. Maintain a citizen system with a fiel...

The concrete implementation of JavaScript exclusive thinking

In the previous blog, Xiao Xiong updated the meth...

jQuery realizes the full function of shopping cart

This article shares the specific code of jQuery t...

Detailed explanation of Angular component projection

Table of contents Overview 1. Simple Example 1. U...

Vue encapsulates the public function method of exporting Excel data

vue+element UI encapsulates a public function to ...

Detailed tutorial on deploying Springboot or Nginx using Kubernetes

1 Introduction After "Maven deploys Springbo...

Introduction to install method in Vue

Table of contents 1. Globally registered componen...

Detailed discussion of the character order of mysql order by in (recommended)

//MySQL statement SELECT * FROM `MyTable` WHERE `...

Solution to input cursor misalignment in Chrome, Firefox, and IE

Detailed explanation of the misplacement of the in...

Simple method to install mysql under linux

When searching online for methods to install MySQ...

Vue+thinkphp5.1+axios to realize file upload

This article shares with you how to use thinkphp5...