Detailed tutorial on installing and configuring MySQL 5.7.20 under Centos7

Detailed tutorial on installing and configuring MySQL 5.7.20 under Centos7

1. Download the MySQL 5.7 installation package from the official website: mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz.

Download address: https://dev.mysql.com/downloads/mysql/

2. Remotely access CentOS7 via SSH Secure Shell Client

3. Uninstall the Mariadb database that comes with the system

4. Create mysql user group and mysql user

5. Upload the MySQL installation package to the CentOS7 server/root directory and decompress it (here I use filezilla to log in to the remote service and then upload the installation package to the root directory. To decompress it, first cd to the directory where the current file is located, and then execute the following directory)

# tar xzvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

6. Move the unzipped installation package to the /data directory and rename it to mysql

# mv /root/mysql-5.7.20-linux-glibc2.12-x86_64 /data/mysq

Here, log in to the service directly with filezilla, create a new data folder, move the unzipped files to the data directory and name it mysql

The results are as follows

7. Modify permissions

8. Create a data directory under the mysql directory as the database storage location

# mkdir /data/mysql/data (here create the data directory under the mysql directory)

9. Initialize mysql

10. Start MySQL and check whether it has started successfully

11. Log in to MySQL with the initial password and change the password

12. Shut down the MySQL service and check whether it is shut down successfully

13. Set the system to start automatically

You can use the service command to control the start and stop of mysql in the future. The commands are: service mysqld start and service mysqld stop. It is possible that an error will be reported during execution, as shown below

This is because MySQL is installed in the /usr/local directory by default. If it is installed in the /usr/local directory, it will start and shut down normally without any errors. However, this installation is in the custom /data directory. At this time, you need to modify the vi /etc/init.d/mysqld file, save and exit

Then execute the service mysqld start command, OK

Then execute the service mysqld stop shutdown command, OK

14. Configure global environment variables

Edit /etc/profile file

# vi /etc/profile

Add the following two lines of configuration at the bottom of the profile file, save and exit

PATH=/data/mysql/bin:/data/mysql/lib:$PATH
export PATH

Setting environment variables takes effect immediately

# source /etc/profile

15. Set up remote host login

First, start the service service mysqld start

Then log in to mysql:# mysql -uroot -p and execute the following command

Remote login failed

Check if port 3306 is open

# netstat -nupl | grep 3306

Open port 3306 and restart the firewall

Log in remotely again, success

16. The End!

After mysql is installed, try to connect to mysql in the program and find that it cannot be connected. The error is as follows

WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

This is a problem with the SSL connection of the MySQL database. The prompt warns that it is not recommended to use SSL connection without server authentication. This problem only occurs in MYSQL versions 5.5.45+, 5.6.26+ and 5.7.6+. The solution is stated in the warning.

Add useSSL=false to the database connection URL;

vi Command

Ctrl+u: scroll half a screen to the beginning of the file;
Ctrl+d: scroll half a screen to the end of the file;
Ctrl+f: scroll one screen to the end of the file;
Ctrl+b: scroll one screen to the beginning of the file;
Esc: Switch from edit mode to command mode;
ZZ: Save the changes made to the current file in command mode and exit vi;
: Line number: The cursor jumps to the beginning of the specified line;
:$: The cursor jumps to the beginning of the last line;
x or X: delete a character, x deletes after the cursor, and X deletes before the cursor;
D: Delete all characters from the current cursor to the end of the line where the cursor is located;
dd: delete the content of the cursor line;
ndd: delete the current row and the next n-1 rows;
nyy: Save the contents of the current line and the next n lines to a register? In, among them? is a letter, n is a number;
p: Paste text operation, used to paste the contents of the buffer area below the current cursor position;
P: Paste text operation, used to paste the contents of the buffer area above the current cursor position;
/String: Text search operation, used to search for the content of a specified string from the current cursor position to the end of the file. The searched string will be highlighted;
? name: text search operation, used to search for the content of a specified string from the current cursor position to the head of the file. The searched string will be highlighted;
a, bs/F/T: replace text operation, used to replace the F string with the T string between line a and line b. Among them, "s/" means to perform a replacement operation;
a: add text after the current character;
A: Add text at the end of the line;
i: insert text before the current character;
I: insert text at the beginning of the line;
o: insert a blank line after the current line;
O: Insert a blank line before the current line;
:wq: In command mode, execute the save and exit operation;
:w: In command mode, execute the save operation;
:w! : In command mode, execute forced save operation;
:q: In command mode, execute the exit vi operation;
:q! : In command mode, execute the forced exit vi operation;
:e file name: In command mode, open and edit the file with the specified name;
:n: In command mode, if multiple files are opened at the same time, continue editing the next file;
:f: In command mode, it is used to display the current file name, the line number of the cursor, and the display ratio;
:set number: In command mode, it is used to display the line number at the far left;
:set nonumber: In command mode, it is used to not display the line number at the far left;

Summarize

This is the end of this detailed tutorial on how to install and configure MySQL 5.7.20 under CentOS 7. For more information about installing and configuring MySQL 5.7.20 on Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to change the password of mysql5.7.20 under linux CentOS 7.4
  • Tutorial on installing lnmp using yum on centos7 (linux+nginx+php7.1+mysql5.7)
  • Summary of Problems in Installing MySQL 5.7.19 under Linux
  • MySQL 5.7.19 (tar.gz) installation graphic tutorial under Linux
  • MySQL 5.7.17 installation and configuration tutorial under Linux (Ubuntu)

<<:  How to use xshell to connect to Linux in VMware (2 methods)

>>:  NodeJS realizes image text segmentation

Recommend

Summary of seven sorting algorithms implemented in JavaScript (recommended!)

Table of contents Preface Bubble Sort Basic Algor...

How to explain TypeScript generics in a simple way

Table of contents Overview What are Generics Buil...

JavaScript color viewer

This article example shares the specific code of ...

In-depth explanation of MySQL isolation level and locking mechanism

Table of contents Brief description: 1. Four char...

Linux uses suid vim.basic file to achieve privilege escalation

Reproduce on Kali First set suid permissions for ...

Native js implementation of slider interval component

This article example shares the specific code of ...

How to add abort function to promise in JS

Table of contents Overview Promise Race Method Re...

How to implement Vue timer

This article example shares the specific code of ...

Detailed explanation of the flexible use of CSS grid system in projects

Preface CSS grids are usually bundled in various ...

Summary of some common uses of refs in React

Table of contents What are Refs 1. String type Re...

Comparison between Redis and Memcache and how to choose

I've been using redis recently and I find it ...

Detailed explanation of filters and directives in Vue

Table of contents vue custom directive Global Dir...

How to use async and await correctly in JS loops

Table of contents Overview (Loop Mode - Common) D...