centos7.6一键式安装mysql5.7.21

执行./mysql.sh内容:

wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
mkdir -p /home/data/server/
rm -rf /etc/my.cnf
cp mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz /home/data/server/
cp mysql.cnf /etc/my.cnf
cd /home/data/server/
tar -xzvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.21-linux-glibc2.12-x86_64 mysql
rm -rf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
groupadd mysql
useradd -r -g mysql mysql
cd mysql
mkdir data
chown -R mysql /home/data/server/mysql/
chgrp -R mysql /home/data/server/mysql/
cd /home/data/server/mysql/bin
yum install -y libaio-devel.x86_64 numactl
./mysqld --initialize --user=mysql --basedir=/home/data/server/mysql/ --datadir=/home/data/server/mysql/data/
mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/log/mariadb/
cd /home/data/server/mysql/support-files/
cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
yum install initscripts -y
service mysql start
chkconfig --add mysql
cd /home/data/server/mysql/bin
./mysql -u root <

涉及到的mysql.cnf内容如下:

[mysqld]
port = 13306
basedir=/home/data/server/mysql
datadir=/home/data/server/mysql/data
max_connections=1000
character-set-server=utf8
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=20M
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
skip-grant-tables=1
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

注意事项:mysql.sh与mysql.cnf一定要放同一个目录哦。

你可能感兴趣的:(mysql)