Detailed steps to install MySQL on CentOS 7

Detailed steps to install MySQL on CentOS 7

In CentOS7, when we install MySQL, MariaDB will be installed by default. It is an open source version launched by the author after MySQL was acquired. However, we may still want to install a more pure MySQL

Download and install the MySQL official Yum Repository

On the official website of MySQL, we can find the download link of Yum Repository.​

wget -i -c https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm​

Using the above command, we have downloaded the Yum Repository, and then we can use yum to install it.​

yum -y install mysql80-community-release-el7-1.noarch.rpm

Next we are going to start installing MySQL

yum -y install mysql-community-server​

MySQL settings

Start MySQL

systemctl start mysqld.service

Check the running status

systemctl status mysqld.service

At this point, our database is already running, but if we want to access our database, we still need to find our root user's password in the log. In new versions, a root user password is generated by default.

grep "passsword" /var/log/mysqld.log​

Through the above command we can view our root user's password.

mysql -uroot -pEnter the password to enter the database.​

Enter the initial password. You cannot do anything at this time because MySQL requires you to change the password by default before you can operate the database:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

The password here must have a certain degree of complexity.

After changing the password we can perform normal operations.

But there is still a problem at this time, that is, because the Yum Repository is installed, each subsequent yum operation will automatically update, so you need to uninstall it:

yum -y remove mysql80-community-release-el7-1.noarch

Startup

shell> systemctl enable mysqld
shell> systemctl daemon-reload

Adding a remote login user

By default, only the root account is allowed to log in locally. If you want to connect to MySQL on other machines, you must modify root to allow remote connections, or add an account that allows remote connections. For security reasons, I add a new account:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'yangxin'@'%' IDENTIFIED BY 'Yangxin0917!' WITH GRANT OPTION;

mysql8 is a little different from the original version. 8 has a higher security level, so when creating a remote connection user, you cannot use the original command (creating a user and granting permissions at the same time):

You must create a user first (password rules: mysql8.0 and above password policy restrictions must be uppercase and lowercase plus numbers and special symbols):​

Create User
mysql>create user chenadmin@'%' identified by 'Chenadmin0.';
Assignment
mysql>grant all privileges on *.* to chenadmin@'%' with grant option;
Last refreshed
mysql>flush privileges;

Configure the default encoding to utf8

Modify the /etc/my.cnf configuration file and add the encoding configuration under [mysqld] as follows:

[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'

Restart mysql service

systemctl restart mysqld

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • MySQL 5.7 installation and configuration tutorial under CentOS7 64 bit
  • A concise tutorial on how to install mysql5.7 decompressed version on CentOS7
  • Centos7 installation and configuration of Mysql5.7
  • MySQL 5.7.17 installation and configuration tutorial under CentOS6.9
  • Detailed tutorial on installing Mysql5.7.19 on Centos7 under Linux
  • How to install mysql5.6 on centos7
  • Centos7 install mysql5.6.29 shell script
  • How to install MySQL on CentOS 7 and set it to start automatically
  • The process of installing MySQL 8.0.26 on CentOS7

<<:  Copy the contents of one file to the end of another file in linux

>>:  Linux Disk Quota Management Graphical Example

Recommend

How to view and clean up Docker container logs (tested and effective)

1. Problem The docker container logs caused the h...

Solve the problem of inconsistent MySQL storage time

After obtaining the system time using Java and st...

JavaScript Html to implement the mobile red envelope rain function page

This article example shares the specific code of ...

Detailed explanation of how to use the Vue license plate input component

A simple license plate input component (vue) for ...

Implementation of Nginx domain name forwarding https access

A word in advance: Suddenly I received a task to ...

How to use binlog for data recovery in MySQL

Preface Recently, a data was operated incorrectly...

React State state and life cycle implementation method

1. Methods for implementing components:組件名稱首字母必須大...

Introduction to container of() function in Linux kernel programming

Preface In Linux kernel programming, you will oft...

MySQL Oracle and SQL Server paging query example analysis

Recently, I have done a simple study on the data ...

Summary of MySQL usage specifications

1. InnoDB storage engine must be used It has bett...

How to read the regional information of IP using Nginx and GeoIP module

Install GeoIP on Linux yum install nginx-module-g...

Solution to failure in connecting to mysql in docker

Scenario: After installing the latest version of ...

Query process and optimization method of (JOIN/ORDER BY) statement in MySQL

The EXPLAIN statement is introduced in MySQL quer...

Detailed explanation of how to use CMD command to operate MySql database

First: Start and stop the mysql service net stop ...