Chapter 1 - MySQL - Introduction and Installation - Ultra-detailed

MySQL - Chapter 1 - Introduction and Installation

4. Enterprise Selection of MySQL Version

4.1 specification

GA Version: Stable Release Version

Version 4.2 Type

E: Enterprise Edition, Charge Edition, SR (Service), Traditional Industry

C: Community Edition, Open Source, Internet Enterprise Choice

4.3 Enterprise Version Selection

Generally new environments, GA will be selected for release in about 6-12 months.

4.4 Enterprise Mainstream Version

Version 5.6: 5.6.34 5.6.36 5.6.38

Version 5.7: 5.7.20 5.7.22 5.7.24

4.5 MySQL Branch

Oracle MySQL

MariaDB

PerconaDB

RDS and Oracle MySQL Most similar

4.6 Software Download

Address: < https://downloads.mysql.com/archives/community/&gt;

5 Installation and Basic Configuration

5.0 Upload and Download Software Package

Create a directory to store software packages

[root@db-01 ~]# mkdir -p /data

Upload software package

Decompress

[root@db-01 data]# tar xf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

1554293722636

5.1 Modify the name

[root@db-01 data]# mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql

5.2 Modify environment variables

[root@db-01 data]# vim /etc/profile

export PATH=/data/mysql/bin:$PATH Additional content

[root@db-01 data]# source /etc/profile #Effective environmental variables

[root@db-01 data]# mysql -V #Testing

mysql Ver 14.14 Distrib 5.7.20, for linux-glibc2.12 (x86_64) using EditLine wrapper

5.3 Clean up History Packages, No Clean Up

[root@db-01 data]# rpm -qa |grep mariadb-libs #Check to see if there are any historical packages; this affects data initialization

mariadb-libs-5.5.56-2.el7.x86_64

[root@db-01 data]# yum remove mariadb-libs -y #Unloading

Loaded plugins: fastestmirror

Resolving Dependencies

--> Running transaction check

5.4 Building Users and Setting up Virtual Users

The function of mysql to manage users needs to be managed by non-root. It can be a virtual user or an ordinary user without password.

[root@db-01 data]# useradd mysql

[root@db-01 data]# id mysql uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)

5.5 Initialization data

Introduction to the Initialization Method of Version 5.5.0

Version 5.6 initialization procedures:

No password and no security policy after initialization

/data/mysql/scripts/mysql_install_db --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data

5.5.0 Create Data Catalog

mkdir -p /data/mysql/data

5.5.1 Download dependency packages

[root@db-01 data]#yum install -y libaio-devel

5.5.2 Initialization (System) Data

Version 5.7.20

[root@db01 data]# /data/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data

Initialization results

Introduction of 5.5.3 Initialization Parameters

initialize-insecure: Data initialization is done in an unrestricted manner

- user=mysql: Setting up the management user of the data

- basedir=/data/mysql: Installation path for software

-- datadir=/data/mysql/data: where the data is stored

5.5.4 Modifying permissions

[root@db01 mysql]# chown -R mysql.mysql /data

5.5.5 Prepare startup scripts and basic configuration files

5.5.5.1 Prepare sys-v startup script

[root@db01 support-files]# pwd

/data/mysql/support-files

[root@db01 support-files]# cp mysql.server /etc/init.d/mysqld

5.5.5.2 Prepare configuration file

vim /etc/my.cnf

[mysqld]

user=mysql

basedir=/data/mysql

datadir=/data/mysql/data

socket=/tmp/mysql.sock

server_id=6

[mysql]

socket=/tmp/mysql.sock

5.5.5.3 SYS-V Startup Database

[root@db-01 ~]# / etc/init.d/mysqld start start

Starting MySQL.Logging to '/data/mysql/data/db-01.err'.

SUCCESS!

[root@db-01 ~]# / etc/init.d/mysqld stop closed

Shutting down MySQL.. SUCCESS!

[root@db-01 ~]# / etc/init.d/mysqld restart restart

ERROR! MySQL server PID file could not be found!

Starting MySQL. SUCCESS!

5.5.5.4 Prepare scripts for sys-d management

vim /etc/systemd/system/mysqld.service

[Unit]

Description=MySQL Server

Documentation=man:mysqld(8)

Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

ExecStart=/data/mysql/bin/mysqld --defaults-file=/etc/my.cnf

LimitNOFILE = 5000

5.5.5 SYS-d Start Database

[root@db-01 ~]# #System CTL status mysqld. service view status

[root@db-01 ~]# #System CTL stop mysqld. service shuts down the service

[root@db-01 ~]# #System CTL start mysqld. service opens the service

[root@db-01 ~]# #System CTL restart mysqld. service restart service

5.6 Connect to Database

mysql

5.7 Setting the initial password for root

[root@db01 ~]# mysqladmin -uroot -p password 123

Keywords: MySQL MariaDB Linux vim

Added by ERuiz on Tue, 14 May 2019 19:13:13 +0300