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

MySQL 8.0.20 installation and configuration detailed tutorial

This article shares with you a detailed tutorial ...

Simple usage example of MySQL 8.0 recursive query

Preface This article uses the new features of MyS...

mysql5.7.17.msi installation graphic tutorial

mysql-5.7.17.msi installation, follow the screens...

HTTP and HTTP Collaboration Web Server Access Flow Diagram

A web server can build multiple web sites with in...

Using CSS to implement loading animation of Android system

There are two common loading icons on the web, on...

What is web design

<br />Original article: http://www.alistapar...

Mysql implementation of full-text search and keyword scoring method example

1. Introduction Today a colleague asked me how to...

Sample code for implementing the Olympic rings with pure HTML+CSS

Rendering Code - Take the blue and yellow rings a...

Some functions of using tcpdump to capture packets in the Linux command line

tcpdump is a flexible and powerful packet capture...

Detailed installation and configuration of Subversion (SVN) under Ubuntu

If you are a software developer, you must be fami...

Share 20 JavaScript one-line codes

Table of contents 1. Get the value of browser coo...

Docker online and offline installation and common command operations

1. Test environment name Version centos 7.6 docke...

Installation and deployment of MySQL Router

Table of contents 01 Introduction to MySQL Router...