Joey
Joey

Reputation: 175

Cannot set limit of MySQL open-files-limit from 1024 to 65535

I have mysql ver. 5.1.49-3, I am working on linux debian. I am trying to set open-files-limit to 65535. so I edited te my.cnf in /etc/mysql/

[mysqld]
open_files_limit = 65535
[mysqld_safe]
open_files_limit = 65535

then in /etc/security/limit.conf

*   soft    nofile  100000
*   hard    nofile  200000

After restarting mysql service, when I run this command in linux

ps -ef|grep mysql

I got 65535. when I log into mysql as root and fetch the value of open-files-limit

show global variables like "%open_files_limit%";

I got 1024. Please help.

Upvotes: 10

Views: 23411

Answers (6)

Djomla
Djomla

Reputation: 616

On Unbuntu 14.04 this worked

vim /etc/mysql/my.cnf 

[mysqld]
open-files-limit=16000

After this, just restart mysql

/etc/init.d/mysql restart

Upvotes: 0

minni
minni

Reputation: 1176

If mysql is started with systemd, this setting is important:

In the file /lib/systemd/system/mysql.service you have to add this 2 lines in the [Service] section at the end:

LimitNOFILE = infinity
LimitMEMLOCK = infinity

After this restart systemctl and mysql:

systemctl daemon-reload
/etc/init.d/mysql restart

To check if the configuration is effective, you can get the parameter from the running mysql process like this:

cat /proc/$(pgrep mysqld$)/limits | grep files

Upvotes: 16

Joey
Joey

Reputation: 175

All I need is to add this line to /etc/pam.d/common-session: session required pam_limits.so

then restart apache

Upvotes: 2

Pol4ko
Pol4ko

Reputation: 1

Take a look at the official documentation:

"The value of this variable at runtime is the real value permitted by the system and might be different from the value you specify at server startup."

Upvotes: 0

PersianGulf
PersianGulf

Reputation: 2935

do ulimit -a for show. ulimit -n NUMBER can change to YOUR_NUMEBR open files

Upvotes: 0

lreeder
lreeder

Reputation: 12224

An issue with older versions of MySQL require you to use use open-files-limit (dashes not underbars) in my.cnf. See http://bugs.mysql.com/bug.php?id=40368

Upvotes: 1

Related Questions