File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ [mysqld]
2+ # mysql 的数据目录
3+ datadir = /var/lib/mysql
4+ # binlog 目录
5+ log_bin = /var/lib/mysql/binlog
6+ # socket 文件
7+ socket = /var/lib/mysql/mysql.sock
8+ # 设置时区
9+ default-time_zone = ' +8:00'
10+ # 数据库默认字符集
11+ character-set-server = utf8mb4
12+ # 数据库字符集对应一些排序等规则,注意要和 character-set-server 对应
13+ collation-server = utf8mb4_0900_ai_ci
14+
15+
16+ # 数据库连接相关设置
17+ # -------------------------------------------------------------------------------
18+ # 最大连接数
19+ max_connections = 10000
20+ # 最大错误连接数
21+ max_connect_errors = 10000
22+ # MySQL打开的文件描述符限制
23+ open_files_limit = 65535
24+
25+
26+ # 日志文件相关设置,一般只开启三种日志,错误日志,慢查询日志,二进制日志。普通查询日志不开启。
27+ # -------------------------------------------------------------------------------
28+ # 错误日志记录的信息
29+ log_error_verbosity = 2
30+ # 错误日志文件地址
31+ log-error = /var/log/mysqld.log
32+ # 开启慢查询
33+ slow_query_log = 1
34+ # 开启慢查询时间,此处为3秒,达到此值才记录数据
35+ long_query_time = 3
36+ # 检索行数达到此数值,才记录慢查询日志中
37+ min_examined_row_limit = 10
38+ # 慢查询日志文件地址
39+ slow-query-log-file = /var/log/mysqld-slow.log
40+ # 开启记录没有使用索引查询语句
41+ log_queries_not_using_indexes = 1
42+ # mysql清除过期日志的时间,默认值0,不自动清理,而是使用滚动循环的方式。这里设置为30天
43+ binlog_expire_logs_seconds = 2592000
44+ # 如果二进制日志写入的内容超出给定值,日志就会发生滚动。你不能将该变量设置为大于1GB或小于4096字节。 默认值是1GB。
45+ max_binlog_size = 1000M
Original file line number Diff line number Diff line change @@ -40,12 +40,22 @@ command -v yum > /dev/null 2>&1 || {
4040}
4141
4242# 使用 rpm 安装 mysql
43+ printf " ${CYAN} >>>> yum install mysql${RESET} \n"
4344wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
4445sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
4546sudo yum install mysql-community-server
4647
48+ printf " ${CYAN} >>>> replace settings${RESET} \n"
49+ cp /etc/my.cnf /etc/my.cnf.bak
50+ wget -N https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/config/mysql/my.cnf -O /etc/my.cnf
51+ # 创建空的慢查询日志文件
52+ touch /var/log/mysqld-slow.log
53+ chmod 777 /var/log/mysqld-slow.log
54+
4755# 设置开机启动
56+ printf " ${CYAN} >>>> start mysqld${RESET} \n"
4857systemctl enable mysqld
58+ systemctl start mysqld
4959systemctl daemon-reload
5060
5161password=$( grep " password" /var/log/mysqld.log | awk ' {print $NF}' )
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ init_sys() {
4848 cat >> /etc/security/limits.conf << EOF
4949* soft nofile 65536
5050* hard nofile 65536
51- * soft nGproc 65536
51+ * soft nproc 65536
5252* hard nproc 65536
5353EOF
5454}
You can’t perform that action at this time.
0 commit comments