Detailed explanation of how to install mysql5.6 from binary installation package in centos7 environment

Detailed explanation of how to install mysql5.6 from binary installation package in centos7 environment

This article describes how to install mysql5.6 using the binary installation package in centos7 environment. Share with you for your reference, the details are as follows:

CentOS 7 binary installation package to install mysql5.6

1. Download the mysql5.6 binary installation package

http://mirrors.sohu.com/mysql/MySQL-5.6/

For example: mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz

2. Install mysql5.6 (installed in /data/mysql56)

(1) Create a MySQL user account

> useradd -s /sbin/nologin -M mysql

(2) Unzip the compressed package

> tar xf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz

(3) Rename

>mv mysql-5.6.34-linux-glibc2.5-x86_64 mysql56

(4) Copy the configuration file

> cp /data/mysql56/support-files/my-default.cnf /etc/my.cnf

Modify the configuration file

[client]
port = 3306
socket = /data/mysql56/mysql.sock
default-character-set = utf8
[mysqld]
skip-name-resolve
user = mysql
basedir = /data/mysql56
datadir = /data/mysql56/data
port = 3306
server_id = 10
socket = /data/mysql56/mysql.sock
pid-file = /data/mysql56/mysql.pid
log-error = /data/mysql56/data/mysql.err
log-bin = /data/mysql56/data/mysql-bin
character-set-server = utf8

(*Binary installation, the default configuration file is in /etc/my.cnf)

(5) Initialize the database

> chown -R mysql.mysql /data/mysq56
> /data/mysql56/scripts/mysql_install_db \
--defaults-file=/etc/my.cnf \
--user=mysql \
--basedir=/data/mysql56 \
--datadir=/data/mysql56/data

If the following message appears

FATAL ERROR: please install the following Perl modules before executing
Data::Dumper

> yum -y install autoconf

This package will install the Data:Dumper module

3. Configure and start mysql

> cp /data/mysql56/support-files/mysql.server /etc/init.d/mysqld
> chmod 755 /etc/init.d/mysqld

(*Note that the default path for MySQL binary installation is /usr/local/mysql, so /usr/local/mysql needs to be replaced in the startup script)

> sed -i 's#/usr/local/mysql#/data/mysql56#g' /data/mysql56/bin/mysqld_safe /etc/init.d/mysqld

Start mysql

> service mysqld start

4. Add auto-start

> chkconfig --add mysqld
> chkconfig mysqld on
> chkconfig --list mysqld

5. Configure environment variables

> echo 'export PATH=/data/mysql56/bin:$PATH' >> /etc/profile
> source /etc/profile

6. Change the mysql password (the default root password for mysql5.6 installation is empty)

>mysqladmin -u root password '123456'

7. Clean up useless MySQL users and libraries

Login to mysql

>mysql -uroot -p

Query User

> select user,host from mysql.user;

As shown below

+------+-----------------------+
| user | host |
+------+-----------------------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | localhost.localdomain |
| root | localhost.localdomain |
+------+-----------------------+

> drop user "root"@"::1";
> drop user ""@"localhost";
> drop user ""@"localhost.localdomain";
> drop user "root"@"localhost.localdomain";

Delete unused libraries

> drop database test;

Readers who are interested in more MySQL-related content can check out the following topics on this site: "MySQL query skills", "MySQL common functions summary", "MySQL log operation skills", "MySQL transaction operation skills summary", "MySQL stored procedure skills" and "MySQL database lock related skills summary"

I hope this article will be helpful to everyone's MySQL database design.

You may also be interested in:
  • Detailed tutorial on setting up multiple instances of MySQL 8 on CentOS 7 (you can have as many as you want)
  • Detailed tutorial on installing MySQL 8.0.20 database on CentOS 7
  • Detailed tutorial on installing mysql 8.0.20 on CentOS7.8
  • Detailed tutorial on how to compile and install mysql8.0.29 in CentOS8 deployment LNMP environment
  • Building a LEMP (Linux+Nginx+MySQL+PHP) environment under CentOS 8.1 (tutorial details)
  • CentOS7.5 installation of MySQL8.0.19 tutorial detailed instructions
  • Tutorial diagram of installing mysql8.0.18 under linux (Centos7)
  • Detailed explanation of the process of deploying MySql on Centos server and connecting to Navicat

<<:  Echart Bar double column chart style most complete detailed explanation

>>:  How to use IDEA to configure tomcat and create JSP files

Recommend

Detailed explanation of the use of Linux lseek function

Note: If there are any errors in the article, ple...

Detailed tutorial on replacing mysql8.0.17 in windows10

This article shares the specific steps of replaci...

Why is there this in JS?

Table of contents 1. Demand 2. Solution 3. The fi...

Steps to create your own YUM repository

To put it simply, the IP of the virtual machine u...

Detailed explanation of adding click event in echarts tooltip in Vue

Table of contents need Workaround 1. Set tooltip ...

MySQL uses find_in_set() function to implement where in() order sorting

This article introduces a tutorial about how to u...

How to upload and download files between Linux server and Windows system

Background: Linux server file upload and download...

Vue project implements left swipe delete function (complete code)

Achieve results The code is as follows html <t...

Two common solutions to html text overflow display ellipsis characters

Method 1: Use CSS overflow omission to solve The ...

Implementation of new issues of CSS3 selectors

Table of contents Basic Selector Extensions Attri...

Examples of new selectors in CSS3

Structural (position) pseudo-class selector (CSS3...

Some details about semicolons in JavaScript

Preface Semicolons in JavaScript are optional, an...

Vue implements the right slide-out layer animation

This article example shares the specific code of ...

Index in MySQL

Preface Let's get straight to the point. The ...