MySQL NOFILE对WSL2的限制



我在WSL2 for 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

并得到以下输出:

* 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

这几乎就像在服务启动时忽略了设置get一样?有人知道把它放在哪里吗?如果没有的话?

您需要检查/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

相关内容

  • 没有找到相关文章

最新更新