mv /var/lib/mysql /datamkdir /data/mysql/logchown mysql:mysql /data/mysql/log
chcon -R -u system_u/data/mysql/log
chcon -Rv -u system_u -t mysqld_db_t /data/mysql
semanage fcontext -a -t mysqld_db_t "/data/mysql(/.*)?"
restorecon -Rv /data/mysql
semanage port -a -t mysqld_port_t -p tcp port_number
# grep "/data/mysql" /etc/selinux/targeted/contexts/files/file_contexts.local
/data/mysql(/.*)? system_u:object_r:mysqld_db_t:s0
/data/mysql system_u:object_r:mysqld_db_t:s0
fixfiles restore
vim/etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[client]
port = 3306
default-character-set = utf8mb4
socket=/data/mysql/mysql.sock
[mysql]
port = 3306
default-character-set = utf8mb4
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/data/mysql
socket=/data/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
############################
## 关闭DNS反向解析
############################
skip-name-resolve
max_allowed_packet = 512M
innodb_log_file_size = 2G
############################
### character set
############################
character-set-server=utf8mb4
collation-server=utf8mb4_bin
##########################
## binlog
###########################
server-id = 6508
###设置日志三种格式:STATEMENT、ROW、MIXED 。
binlog_format = mixed
###设置日志路径,注意路经需要mysql用户有权限写
log-bin = /data/mysql/logs/mysql-bin.log
###设置binlog清理时间
expire_logs_days = 7
###binlog每个日志文件大小
max_binlog_size = 100m
###binlog缓存大小
binlog_cache_size = 4m
###最大binlog缓存大小
max_binlog_cache_size = 512m
##############################
##slowlog
##############################
###设置日志开启
slow_query_log =1
###设置日志路径
slow_query_log_file=/data/mysql/logs/mysql-slow.log
###设置超过时长日志记录
long_query_time = 2