Centos7 binary install mysql5.6

1. Download the mysql5.6 binary installation package

wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

Such as: mysql-5.6.35-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 
-s indicates the shell used by the specified user, here is /sbin/nologin`, indicating no login. 
-M means do not create user home directory.

(2), decompress the compressed package

tar -zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

(3), rename

mv mysql-5.6.35-linux-glibc2.5-x86_64 mysql56

(4), copy the configuration file

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

Modify the configuration file

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

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

(5), install dependencies

yum install libaio -y ;
yum -y install autoconf ;

(6), initialize the database

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

3. Configure and start mysql

cp /opt/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, and /usr/local/mysql needs to be replaced in the startup script)

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

start mysql

service mysqld start

Fourth, add self-start

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

Five, configure environment variables

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

Six, modify the mysql password (mysql5.6 installation default root password is empty)

mysqladmin -u root password '123456'

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324725578&siteId=291194637