如何修复 mysql 错误日志中的 "mbind: Operation not permitted"

How to fix "mbind: Operation not permitted" in mysql error log

我的 MySQL 错误日志有问题,目前主要由 "mbind: Operation not permitted" 行组成(见下文)。为什么会发生,我该如何解决?

困扰我的是 "mostly" 部分。如下所示,并非所有行都是 "mbind: Operation not permitted"。我怀疑 MySQL 查询错误应该是而不是那一行,但由于某些原因它们不能写入文件。

MySQL 本身是一个 Docker 容器,日志文件通过以下方式进行存储:

volumes:
- ./mysql/log:/var/log/mysql

有趣的是:

有什么想法吗?提前谢谢你。

2019-04-07T12:56:22.478504Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2019-04-07T12:56:22.478533Z 0 [Warning] [MY-011068] [Server] The syntax 'expire-logs-days' is deprecated and will be removed in a future release. Please use binlog_expire_logs_seconds instead.
2019-04-07T12:56:22.478605Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.15) starting as process 1
2019-04-07T12:56:22.480115Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2019-04-07T12:56:22.480122Z 0 [Warning] [MY-013244] [Server] --collation-server: 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
[same line goes forever]

P.S。 MySQL 启动并运行良好,没问题。就是这个 error.log 一直困扰着我,让我看不到真正的错误。

在docker-compose.yml中添加security_opt选项有助于解决这个问题:

database:
  image: mysql:latest
  container_name: mysql_0
  ports:
    - "3306:3306"
  security_opt:
    - seccomp:unconfined

将功能 CAP_SYS_NICE 添加到您的容器,直到 MySQL 服务器可以“静默”处理错误。

service:
  mysql:
    image: mysql:8.0.15
    # ...
    cap_add:
      - SYS_NICE  # CAP_SYS_NICE

如果你没有docker-compose,那么你可以通过

定义CAP_SYS_NICE
docker run --cap-add=sys_nice -d mysql

参考文献: