Centos7.5 mysql5.7.26 binary installation

. 1    yum install dependent packages required.

yum -y install gcc-c++

yum -y install zlib zlib-devel pcre pcre-devel

yum -y install openssl-devel

yum -y install libaio-devel.x86_64

2 Search Keyword: MySQL5.7 Linux binary installation

Download Path:

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

# 2.1 Create a mysql data directory, which is in the waiting initialize the database will be used

mkdir -p /data/mysql/data

mkdir -p /data/mysql/log

 

# 2.2 moved mysql files to / data / mysql / mysql

tar -zxvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

cd /usr/local/

ln -s mysql-5.7.26-linux-glibc2.12-x86_64 mysql

2.3 # create mysql group

groupadd mysql

# 2.4 The MySQL users to join the mysql group

useradd -r -g mysql -s /bin/false mysql     

2.5 # modify directory permissions

chown -R mysql:mysql /data/mysql/

chmod 750 /data/mysql

2.6 # Configure my.cnf

/etc/my.cnf the -l LS ## View is not already there my.cnf configuration, and if there may be centos comes with Mysql database, I use 7.5 , comes with mysql 's MariaDB , I'll refer to it unloading, to avoid interference

rpm -e mariadb-libs --nodeps ##mariadb

       vim /etc/my.cnf   

[client]

port = 3306

socket = /data/mysql/mysql.sock

[mysqld]

server_id=10

port = 3306

user = mysql

character-set-server = utf8mb4

default_storage_engine = innodb

log_timestamps = SYSTEM

socket = /data/mysql/mysql.sock

basedir =/usr/local/mysql

datadir = /data/mysql/data

pid-file = /data/mysql/mysql.pid

max_connections = 1000

max_connect_errors = 1000

table_open_cache = 1024

max_allowed_packet = 128M

open_files_limit = 65535

server-id=1

gtid_mode=on

enforce_gtid_consistency=on

log-slave-updates=1

log-bin=master-bin

log-bin-index = master-bin.index

relay-log = relay-log

relay-log-index = relay-log.index

binlog_format=row

log_error = /data/mysql/log/mysql-error.log 

skip-name-resolve

log-slave-updates=1

relay_log_purge = 0 

slow_query_log = 1

long_query_time = 1 

slow_query_log_file = /data/mysql/log/mysql-slow.log

 

 

 

2.7 # initialize the database

 

/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql --basedir=/data/mysql/mysql --datadir=/data/mysql/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp #初始化mysql

# 2.7 Depending on the configuration of the my.cnf 's error.log , view the initial password

grep 'password' /data/mysql/log/mysql-error.log  

 2.8 # create ssl encryption

/usr/local/mysql/bin/mysql_ssl_rsa_setup --datadir=/data/mysql/data

# 2.9 will be inside of the basedir and datadir changed and my.cnf consistent

we /usr/local/mysql/support-files/mysql.server            

basedir=/usr/local/mysql

datadir=/data/mysql/data

2.10 # copy startup files and configuration

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld     

2.11 Setting the boot

chkconfig --add mysqld

chkconfig mysqld on

 

2.12 configuration environment variable

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

tail -1 /etc/profile

Source / etc / Profile   # make the environment variables to take effect

the PATH $ echo # check whether to add variable success

2.13 # start mysql

service mysqld start 

2.14 # enter mysql

-p-uroot-MySQL         # password by previous 2.2.7 found

2.15 # modify the initial password

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';    

2.16 # refresh permission

flush privileges; 

2.17 Join boot entry

[root@Smile system]# vim /usr/lib/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=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf

LimitNOFILE = 5000

X + the chmod / usr / lib / systemd / System / mysqld.service ## administered execute permissions

daemon-reload systemctl ### reload

systemctl enable mysqld.service

systemctl start mysqld.service

 

Published 447 original articles · won praise 71 · Views 400,000 +

Guess you like

Origin blog.csdn.net/w892824196/article/details/104062528