linux mysql 最大连接数限制_Linux下修改Mysql最大并发连接数

输入的命令如下:

/usr/local/mysql/bin/mysqladmin -uroot -pyyyyyy variables |grep max_connections

nano /etc/my.cnf

max_connections=200

service mysql restart

在mysql中最大并发连接数修改方法只要在my.cnf文件加找到max_connections 或修改max_connections 的参考即可了,后面的参数越大就是并发越大了

1.先查看下当前MYSQL的最大连接数 注意,root替换成你的数据库,不过一般默认就是root,password是数据库密码,) 入以上命令后会显示下面的信息,这个是最大连接数是100

[[email protected] ~]# /usr/local/mysql/bin/mysqladmin -uroot -pyyyyyyyy variables |grep max_connections

2.修改最大连接数为200

[[email protected] ~]# nano /etc/my.cnf

输入以上命令后会进入my.cnf文件内容,在其中加入下面这行代码

max_connections=200

使用上下箭头移动光标,输入后按ctrl+o组合键后保存,保存的时候要再按回车键确定的,确定后按ctrl+x组合键退出回到命令行

3.最后一步就是重启mysql [[email protected] ~]#  service mysql restart //重启mysql的命令

LINUX命令界面如下:

Xshell for Xmanager Enterprise 5 (Build 0488) Copyright (c) 2002-2014 NetSarang Computer, Inc. All rights reserved.

Type `help‘ to learn how to use Xshell prompt. [c:\~]$

Connecting to 203.86.8.114:22... Connection established. To escape to local shell, press ‘Ctrl+Alt+]‘.

WARNING! The remote SSH server rejected X11 forwarding request. Last login: Wed Aug 19 17:25:35 2015 from 61.143.61.19 [[email protected] ~]#/usr/local/mysql/bin/mysqladmin -uroot -pyyyyyy variables |grep max_connections | max_connections                         | 10

| [[email protected] ~]# nano /etc/my.cnf

[[email protected] ~]# /usr/local/mysql/bin/mysqladmin -uroot -pzhengou$%#1980 variables |grep max_connections error: Found option without preceding group in config file: /etc/my.cnf at line: 3 Fatal error in defaults handling. Program aborted /usr/local/mysql/bin/mysqladmin: connect to server at ‘localhost‘ failed error: ‘Too many connections‘

[[email protected] ~]#service mysql restart error: Found option without preceding group in config file: /etc/my.cnf at line: 3 Fatal error in defaults handling. Program aborted error: Found option without preceding group in config file: /etc/my.cnf at line: 3 Fatal error in defaults handling. Program aborted error: Found option without preceding group in config file: /etc/my.cnf at line: 3 Fatal error in defaults handling. Program aborted error: Found option without preceding group in config file: /etc/my.cnf at line: 3 Fatal error in defaults handling. Program aborted Shutting down MySQL..                                      [确定] error: Found option without preceding group in config file: /etc/my.cnf at line: 3 Fatal error in defaults handling. Program aborted error: Found option without preceding group in config file: /etc/my.cnf at line: 3 Fatal error in defaults handling. Program aborted Starting MySQL.                                            [确定]

[[email protected] ~]# /usr/local/mysql/bin/mysqladmin -uroot -pyyyyyyy variables |grep max_connections error: Found option without preceding group in config file: /etc/my.cnf at line: 3 Fatal error in defaults handling. Program aborted | max_connections                         | 151                                                                                       |

[[email protected] ~]# nano /etc/my.cnf

GNU nano 1.3.12                File: /etc/my.cnf

max_connections=200

# Example MySQL config file for medium systems. # # This is for a system with little memory (32M - 64M) where MySQL plays # an important part, or systems up to 128M where MySQL is used together with # other programs (such as a web server) # # MySQL programs look for option files in a set of # locations which depend on the deployment platform. # You can copy this option file to one of those # locations. For information about these locations, see: # http://dev.mysql.com/doc/mysql/en/option-files.html # # In this file, you can use all long options that a program supports. # If you want to know which options a program supports, run the program # with the "--help" option.

# The following options will be passed to all MySQL clients [client]                                     [ Read 146 lines ] ^G Get Help    ^O WriteOut    ^R Read File   ^Y Prev Page   ^K Cut Text    ^C Cur Pos ^X Exit        ^J Justify     ^W Where Is    ^V Next Page   ^U UnCut Text  ^T To Spell

原文:http://www.cnblogs.com/Snowfun/p/4742933.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要增加 MySQL最大连接数,你需要修改 MySQL 的配置文件。下面是一些常见的步骤: 1. 找到 MySQL 的配置文件:MySQL 的配置文件通常是 `my.cnf`(对于 Linux 和 macOS)或 `my.ini`(对于 Windows)。在 Linux 上,通常位于 `/etc/mysql/` 或 `/etc/` 目录下。在 Windows 上,通常位于 MySQL 安装目录下。 2. 备份配置文件:在进行任何修改之前,请先备份 MySQL 的配置文件,以防止意外的错误。 3. 打开配置文件并找到 `max_connections` 参数:在配置文件中找到 `max_connections` 参数,它控制了 MySQL 数据库的最大连接数。该参数通常位于 `[mysqld]` 部分下。 4. 修改 `max_connections` 参数:将 `max_connections` 参数的值增加到你想要的最大连接数。你可以根据你的应用程序需求和服务器资源来设置合适的值。建议根据服务器的硬件配置和预计的并发连接数来调整该值,以避免过度消耗服务器资源。 5. 保存并关闭配置文件:保存对配置文件的修改,并关闭文件。 6. 重启 MySQL 服务:重新启动 MySQL 服务以使配置更改生效。在 Linux 上,可以使用以下命令重启 MySQL 服务: ```bash sudo service mysql restart ``` 在 Windows 上,可以在服务管理器中找到 MySQL 服务并重新启动它。 7. 验证最大连接数:连接到 MySQL 数据库并执行以下查询语句来验证最大连接数是否已经增加: ```sql SHOW VARIABLES LIKE 'max_connections'; ``` 查询结果中的 `Value` 字段将显示当前的最大连接数。 需要注意的是,增加最大连接数可能会增加服务器的负载和资源消耗。确保你的服务器有足够的资源来支持所需的连接数,并注意监控服务器性能以及调整其他相关参数,如线程缓存、内存等。 希望这些步骤能够帮助你增加 MySQL最大连接数。如有其他疑问,请随时提出。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值