簡體   English   中英

MySQL NOFILE 對 WSL2 的限制

[英]MySQL NOFILE limits on WSL2

我在 WSL2 上為 Windows 運行 MySQL。 在 WSL2 啟動時,MySQL 沒有啟動,我收到以下錯誤:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

然后我運行這個命令來讓它運行:

sudo service mysql start

並得到以下output:

 * Starting MySQL database server mysqld
 su: warning: cannot change directory to /nonexistent: No such file or directory
[ OK ]

當我檢查我的 MySQL 錯誤日志時,我看到有關 max_open_files 和 table_open_cache 的以下錯誤:

2022-07-28T08:36:34.074107Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8161)
2022-07-28T08:36:34.074111Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 431 (requested 4000)

我的理解是我需要編輯我的/lib/systemd/system/mysql.service文件來更改它,但是當我檢查該文件時,我看到LimitNOFILE已經設置為 10000

# MySQL systemd service file

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

[Install]
WantedBy=multi-user.target

[Service]
Type=notify
User=mysql
Group=mysql
PIDFile=/run/mysqld/mysqld.pid
PermissionsStartOnly=true
ExecStartPre=/usr/share/mysql/mysql-systemd-start pre
ExecStart=/usr/sbin/mysqld
TimeoutSec=infinity
Restart=on-failure
RuntimeDirectory=mysqld
RuntimeDirectoryMode=755
LimitNOFILE=10000

# Set enviroment variable MYSQLD_PARENT_PID. This is required for restart.
Environment=MYSQLD_PARENT_PID=1

幾乎就好像該設置在服務啟動時被忽略了? 如果不是這樣,有誰知道在哪里設置它?

您需要檢查/etc/security/limits.conf中的信息您可以添加類似的內容(假設您以mysql用戶身份運行mysqld

mysql           hard    nofile     10000
mysql           soft    nofile      8192    

my.cnf

[mysqld]
open_files_limit = 10000
table_open_cache=4096

然后注銷,登錄並重新啟動mysql

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM