8 月 022018
 

https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_max_connections

系统变量属性

Property Value
Command-Line Format --max-connections=#
System Variable max_connections
Scope Global
Dynamic Yes
Type integer
Default Value 151
Minimum Value 1
Maximum Value 100000

查看最大连接数

mysql> show variables like "max_connections";
+-----------------------------------------------+-----------------+
| Variable_name | Value |
+-----------------------------------------------+-----------------+
| max_connections | 151 |
+-----------------------------------------------+-----------------+
1 rows in set (0.00 sec)

mysql> show variables like "max_connections";
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_connections | 214 |
+--------------------+-------+
1 rows in set (0.00 sec)

修改

[root@localhost ~]# cat /usr/lib/systemd/system/mysqld.service
#
# Simple MySQL systemd service file
#
# systemd supports lots of fancy features, look here (and linked docs) for a full list:
# http://www.freedesktop.org/software/systemd/man/systemd.exec.html
#
# Note: this file ( /usr/lib/systemd/system/mysql.service )
# will be overwritten on package upgrade, please copy the file to
#
# /etc/systemd/system/mysql.service
#
# to make needed changes.
#
# systemd-delta can be used to check differences between the two mysql.service files.
#

[Unit]
Description=MySQL Community Server
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target
Alias=mysql.service

[Service]
User=mysql
Group=mysql

# Execute pre and post scripts as root
PermissionsStartOnly=true

# Needed to create system tables etc.
ExecStartPre=/usr/bin/mysql-systemd-start pre

# Start main service
ExecStart=/usr/bin/mysqld_safe --basedir=/usr

# Don't signal startup success before a ping works
ExecStartPost=/usr/bin/mysql-systemd-start post

# Give up if ping don't get an answer
TimeoutSec=600

Restart=always
PrivateTmp=false

LimitNOFILE=65535
LimitNPROC=65535
[root@localhost ~]#

重启服务

[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart mysqld

查看最大连接数

mysql> show variables like 'max_connections';
+--------------------------+-----------------+
| Variable_name | Value |
+--------------------------+-----------------+
| max_connections | 5000 |
+--------------------------+-----------------+
1 rows in set (0.01 sec)

mysql>

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)