How to install MySQL 5.7.28 binary mode under CentOS 7.4

How to install MySQL 5.7.28 binary mode under CentOS 7.4

Linux system version: CentOS7.4

MySQL version: 5.7.28

There are three installation methods on the Linux platform: RPM package, binary package, and source package. This article mainly uses the RPM package as an example to introduce how to install MySQL on the Linux platform.

Download address:

https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz


The specific installation steps are as follows:

(1) First uninstall mariadb, otherwise it will conflict with the library required for installing mysql:

[root@localhost ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

(2) Log in to the system as the root user, add the mysql user and group, and install the database under this user:

[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -r -g mysql -s /bin/false mysql

(3) Prepare the data directory

Taking /app/data as an example, it is recommended to use a logical volume

[root@localhost ~]# mkdir -p /app/data
[root@localhost ~]# chown mysql.mysql /app/data/
[root@localhost ~]# chmod 750 /app/data

(4) Prepare binary files:

[root@localhost ~]# tar xvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
root@localhost ~]# cd /usr/local
[root@localhost local]# ln -sv mysql-5.7.28-linux-glibc2.12-x86_64 mysql
'mysql' -> 'mysql-5.7.28-linux-glibc2.12-x86_64'

(5) Initialize MySQL:

[root@localhost ~]# cd /usr/local/mysql
[root@localhost mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/app/data
2019-11-03T09:47:18.263716Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-11-03T09:47:19.059462Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-11-03T09:47:19.140866Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-11-03T09:47:19.207569Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ed1cd8ec-fe1e-11e9-8c9c-000c29f8617a.
2019-11-03T09:47:19.209181Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-11-03T09:47:19.646366Z 0 [Warning] CA certificate ca.pem is self signed.
2019-11-03T09:47:20.056792Z 1 [Note] A temporary password is generated for root@localhost: rY-6f??#!<zO

Among them, --basedir mysql base directory --datadir mysql data storage directory, and created a temporary password for the root user: rY-6f??#!<zO

(6) Enable SSL connection:

[root@localhost mysql]# bin/mysql_ssl_rsa_setup
2019-11-03 23:09:55 [ERROR] Failed to access directory pointed by --datadir. Please make sure that directory exists and is accessible by mysql_ssl_rsa_setup. Supplied value : /usr/local/mysql/data
[root@localhost mysql]# bin/mysql_ssl_rsa_setup --datadir=/app/data

If no parameter is added after the command, an error is reported. If --datadir is added, no error is reported.

(7) Edit the configuration file, save and exit:

[root@localhost mysql]# vim /etc/my.cnf
[mysqld]
#GENERAL
datadir=/app/data
socket=/app/data/mysql.sock
user=mysql
default-storage-engine=InnoDB

[mysqld_safe]
log-error=/app/data/mysql-error.log
pid-file=/app/data/mysqld.pid

[client]
socket=/app/data/mysql.sock

(8) Start MySQL:

[root@localhost mysql]# bin/mysqld_safe --user=mysql &

(9) Configure environment variables:

[root@localhost ~]# vim /etc/profile
#Add the following line export PATH=$PATH:/usr/local/mysql/bin
[root@localhost ~]# source /etc/profile

(10) Set the startup:

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql.server
[root@localhost mysql]# chkconfig --add mysql.server

(11) Test login success:

[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

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:
  • Binary installation of mysql 5.7.23 under CentOS7
  • Deploy MySQL 5.7.17 binary installation and multi-instance configuration on CentOS 6.5

<<:  JavaScript object built-in objects, value types and reference types explained

>>:  Detailed explanation of the differences between SQL joint query inner join, outer join and cross join

Recommend

TypeScript union types, intersection types and type guards

Table of contents 1. Union Type 2. Crossover Type...

JS achieves five-star praise case

This article shares the specific code of JS to ac...

Docker Detailed Illustrations

1. Introduction to Docker 1.1 Virtualization 1.1....

The grid is your layout plan for the page

<br /> English original: http://desktoppub.a...

Why MySQL should avoid large transactions and how to solve them

What is a big deal? Transactions that run for a l...

How to install MySQL server community version MySQL 5.7.22 winx64 in win10

Download: http://dev.mysql.com/downloads/mysql/ U...

Detailed explanation of dynamically generated tables using javascript

*Create a page: two input boxes and a button *Cod...

How to change password in MySQL 5.7.18

How to change the password in MySQL 5.7.18: 1. Fi...

Solve the compatibility issue between MySQL 8.0 driver and Alibaba Druid version

This article mainly introduces the solution to th...

How to retrieve password for mysql 8.0.22 on Mac

Mac latest version of MySQL 8.0.22 password recov...

Use a table to adjust the format of the form controls to make them look better

Because I want to write a web page myself, I am al...

MySQL stored procedures and common function code analysis

The concept of mysql stored procedure: A set of S...

Let's talk about bitwise operations in React source code in detail

Table of contents Preface Several common bit oper...