Installation of MySQL 5.7 series of tutorials


MySQL Installation

1. This document is based on linux (CentOS6, CentOS7) system only.
2. Use version MySQL 5.7.20
3. Refer to the official document

Preparing for Planning

1. Choose the appropriate version:
2. Turn off SELINUX to avoid unnecessary trouble

#vi /etc/selinux/config   
#setenforce 0

3. Firewall settings

#vim /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
#Service iptables restart -- Restart


Add to:
#firewall-cmd --zone=public --add-port=3306/tcp --permanent
#firewall-cmd --reload
#View all ports
#firewall-cmd --zone=public --list-ports

4. After installation (before startup), it is recommended to re-plan the database directory by default: / var/lib/mysql
5. Open logbin (similar to oracle's archive log, strongly recommended to open production environment, and regularly clean logs)
6. Verify rpm packages (e.g. rpm packages obtained through informal channels)

shell> rpm --checksig package_name.rpm

The main file path [MySQL Installation Layout for Linux RPM Packages from the MySQL Developer Zone];

Prior to MySQL 5.7.5, mysql_install_db created a default option file named my.cnf in the basic installation directory. This file is my-default.cnf created from a template named in the distribution package. Since MySQL 5.7.18, my-default.cnf is no longer included in or installed by distribution packages.

Binary Installation

Install dependency packages:
#yum install libaio

#groupadd mysql
#useradd -r -g mysql -s /bin/false mysql
#cd /usr/local
#tar zxvf /path/to/mysql-VERSION-OS.tar.gz
#ln -s full-path-to-mysql-VERSION-OS mysql
#cd mysql
#mkdir mysql-files
#chmod 750 mysql-files
#chown -R mysql .
#chgrp -R mysql .
#bin/mysql_install_db --user=mysql    # MySQL 5.7.5
#bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up
#bin/mysql_ssl_rsa_setup              # MySQL 5.7.6 and up
#chown -R root .
#chown -R mysql data mysql-files
#bin/mysqld_safe --user=mysql &
# Next command is optional
#cp support-files/mysql.server /etc/init.d/mysql.server

yum offline installation

1.	To configure yum Source (This method is applicable to users who cannot connect to the external network, and can be skipped directly if the host can connect to the network)
//After the download (mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar) is decompressed, place it under / root/mysql/.
# vim /etc/yum.repos.d/mysql.repo
//Establishing Dependent Relational Database File repodata
#createrepo /root/mysql/
//View compilation results
# yum repolist
[The rest are the same: yum Online Installation]

yum online installation

1.To configure yum Source, select and download the distribution package for your platform.
//Install the downloaded version package with the following commands, and replace platform-and-version-specific-package-name with the name of the downloaded RPM package:
# yum localinstall mysql57-community-release-el{version}-{version-number}.noarch.rpm -y
yum install mysql-community-server -y
//Set up the database directory (default / var/lib/mysql uses cp - p to copy directory permissions together)
# cp -rp /var/lib/mysql /home/mysql
vim /etc/my.cnf
# ERROR 2002 without login

3. Start-up

When the server is initially started, if the server's data directory is empty, the following will happen:
1 Server has been initialized.
2. The SSL certificate and key files are generated in the data directory.
The 3validate_password plug-in is installed and enabled.
4'root'@ localhost creates a superuser account. The password settings of the superuser are stored in the error log file. To display it, use the following commands:
grep 'temporary password' /var/log/mysqld.log
 Log in using the generated temporary password, change the root password as soon as possible, and set a custom password for the superuser account:
mysql -uroot -p 
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
Adding Network Access Permissions
grant all privileges on *.* to root@'%' identified by 'MyNewPass4!' WITH GRANT OPTION;
flush privileges;
Be careful
 MySQL's validate_password plug-in is installed by default. This will require a password to contain at least one capital letter, a lowercase letter, a number and a special character, and a total password length of at least eight characters.
The installation also creates a user named mysql and a group named mysql on the system

Single-machine multi-instance configuration

Tags: MySQL RPM yum firewall

Posted on Tue, 13 Aug 2019 05:50:30 -0700 by micaudwell