$ mongo MongoDB shell version v4.0.2 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 4.0.2 Server has startup warnings: 2018-10-25T20:07:13.893+0800 I CONTROL [initandlisten] 2018-10-25T20:07:13.893+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2018-10-25T20:07:13.893+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2018-10-25T20:07:13.893+0800 I CONTROL [initandlisten] 2018-10-25T20:07:13.893+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost. 2018-10-25T20:07:13.893+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server. 2018-10-25T20:07:13.893+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP 2018-10-25T20:07:13.893+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to 2018-10-25T20:07:13.893+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the 2018-10-25T20:07:13.893+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning. 2018-10-25T20:07:13.893+0800 I CONTROL [initandlisten] --- Enable MongoDB's free cloud-based monitoring service, which will then receive and display metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you and anyone you share the URL with. MongoDB may use this information to make product improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring() To permanently disable this reminder, run the following command: db.disableFreeMonitoring() ---
通过Navicat客户端连接Mysql数据库时,出现too many connections的提示,可以进行如下操作
登录mysql数据库
1 2 3 4 5 6 7 8 9 10 11 12 13
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2965 Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show variables like "max_connections"; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 151 | +-----------------+-------+ 1 row in set (0.01 sec)
当processlist的数量大于查询到的max_connections时,就会出现too many connections的提示信息。
修改最大连接数
1
set GLOBAL max_connections=1000;
这不是一劳永逸的方法,应该要让它自动杀死那些sleep的进程。
查看关闭一个连接的等待时间,并修改
1 2
show global variables like 'wait_timeout'; set global wait_timeout=300;
修改这个数值,这里可以随意,最好控制在几分钟内。
其他待验证
set global interactive_timeout=500; 修改这个数值,表示mysql在关闭一个连接之前要等待的秒数,至此可以让mysql自动关闭那些没用的连接,但要注意的是,正在使用的连接到了时间也会被关闭,因此这个时间值要合适
为了防止发生too many connections时候无法登录的问题,mysql manual有如下的说明:
mysqld actually allows max_connections+1 clients to connect. The extra connection is reserved for use by accounts that have theSUPER privilege. By granting the SUPER privilege to administrators and not to normal users (who should not need it), an administrator can connect to the server and use SHOW PROCESSLIST to diagnose problems even if the maximum number of unprivileged clients are connected.