You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何MariaDB中mysqld_safe生效open_files_limit而mysqld不生效?

Why open_files_limit Isn't Working for mysqld (But Works for mysqld_safe)

Hey there, let's dig into why your open_files_limit setting isn't taking effect on the mysqld process—this is a common gotcha with MySQL/MariaDB configs. Here's the breakdown:

1. You Used the Wrong Configuration Section

The [mysql] block in my.cnf is designed for the MySQL client tool (the interactive mysql command you use to connect to the server), not the mysqld database daemon itself. That's why the setting only affected mysqld_safe (and likely by accident, not intentional) but ignored the actual server process.

To fix this, move your open_files_limit = 32000 line to one of these sections instead:

  • [mysqld]: This directly targets the database server process, so the limit will apply to mysqld directly.
  • [mysqld_safe]: Since mysqld_safe is the wrapper script that launches mysqld, setting it here will pass the limit to the child mysqld process (useful for older distributions or systems where direct mysqld config is restricted).

2. System-Level Limits Might Be Blocking Your Setting

Even if you fix the config section, system-enforced limits could override your MariaDB setting. Check these two key spots:

  • /etc/security/limits.conf: Ensure the mysql user has permission to open enough files. Add these lines if they're missing:
    mysql soft nofile 32000
    mysql hard nofile 32000
    
  • Systemd Service Limits (if using systemd): If MariaDB is managed by systemd, the service file may restrict open files. Edit the service file (usually /etc/systemd/system/mariadb.service or /usr/lib/systemd/system/mariadb.service) and add this under the [Service] block:
    LimitNOFILE=32000
    
    Then run systemctl daemon-reload and restart MariaDB to apply the change.

3. Verify the Fix

After making these adjustments, restart MariaDB:

systemctl restart mariadb  # Or `service mariadb restart` for non-systemd systems

Then check the mysqld process limits again:

cat /proc/$(pgrep mysqld)/limits | grep "Max open"

You should now see the limit set to 32000.


内容的提问来源于stack exchange,提问作者Samuel Mutel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:32:08