CentOS 7 install MySQL 5.6

Environment: CentOS7 Software: MySQL5.6.26

It is recommended to run the following command before installation to configure the required environment:

yum install libaio #Install libaio
yum install deltarpm #Install deltarpm
yum install perl-Data-Dumper.x86_64 #Install Perl modules

1 Download MySQL source package

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz

2 Unzip the downloaded file to the /usr/local directory and modify the folder name to mysql

tar -zxvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz  -C /usr/local
mv mysql-5.6.26-linux-glibc2.5-x86_64/ mysql

3 Create Mysql user and user group

useradd mysql -s /sbin/nologin

4 Create a Mysql database directory and grant permissions to Mysql users

mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
chown -R mysql:mysql /usr/local/mysql

5 Enter the /usr/local/mysql directory to initialize mysql

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

6 Back up the my.cnf file that comes with the system, and then move the default configuration file in the Mysql decompression directory.

mv /etc/my.cnf /etc/my.cnf.bak
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

7 Modify the my.cnf file

datadir=/data/mysql
port=3306
socket=/tmp/mysql.sock

8 Copy the mysql.server file in the unzipped directory to /etc/init.d/mysqld

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod 755/etc/init.d/mysqld
vi /etc/init.d/mysqld
datadir=/data/mysql   #Modify the database directory file
basedir=/usr/local/mysql

9 Start mysql service

service mysqld start
 
Usage: mysqld  {start|stop|restart|reload|force-reload|status}[ MySQL server options ]

10 Configure mysql environment variables

echo "PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
source /etc/profile

11 Log in to mysql

[ root@localhost ~]# mysql -uroot -p #No password is required for the first login, just press enter
Enter password: 
Welcome to the MySQL monitor.  Commands end with; or \g.
Your MySQL connection id is 2
Server version:5.6.26 MySQL Community Server(GPL)Copyright(c)2000,2015, 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> update mysql.user set password=password("123456") where user="root"; #Modify root password
flush privileges;

12 Set character encoding to UTF-8

Please refer to: The modified character set encoding of MySQL 5.5/5.6 under Linux is UTF8. The installation is complete.

Recommended Posts

CentOS7.2 install Mysql5.7.13
CentOS install mysql
CentOS 7 install MySQL 5.6
CentOS8 install MySQL8.0
CentOS7 install mysql8
CentOS7 install MySQL8
centos 7.5 install mysql5.7.17
CentOS6.5 offline install MySQL5.6.26
Install MySQL5.7 in centos7
CentOS 7.2 Yum install MySQL 5.6
Centos7 install Mysql8 tutorial
Install mysql under Centos 7
Centos7 install Mysql database
Install mysql5.1 under CentOS6.5
1.5 Install Centos7
Install mysql online on centos
centos install mysql through yum
Install MySQL 8.0.16 on Linux Centos
Install MySQL under Linux (CentOS 7)
Centos6 install mysql 5.7.x series
CentOS8 install MySQL8 (pro test)
Centos6 install Python2.7.13
How to install MySQL on CentOS 8
CentOS7 yum install and start mysql
CentOS install Redmine
Centos7 install Python 3.6.
CentOS 7 install Docker
CentOS 7 install Nginx, PHP, MySQL packages
CentOS7 install GlusterFS
CentOS 7.4 install Zabbix 3.4
CentOS7 install Docker
Centos6.5 install Tomcat
CentOS install Python 3.6
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
Install MySql with Docker in CentOS7
Centos7 install Python2.7
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
Install MySQL on Linux CentOS7 (Windows)
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS install PHP
CentOS7 yum install and start mysql
CentOS6 install mist.io
Centos7 install Docker
Centos7 and centos8 install mysql5.6 5.7 8.0 so simple
centOs install rabbitMQ
Centos7 install Nginx
CentOS6.5 install CDH5.13
Centos7 install docker18
Centos install Python3
centos7 install docker
CentOS install jdk
centos7 install nginx-rtmp
Centos6.3 install KVM
CentOS install PostgreSQL 9.1
centos7 .*tar package to install MySQL5.7
CentOS 7 install Java 1.8
CentOS8 install fastdfs6.06