0

Im facing a problem when trying to run a MySQL 8.0 Docker in a Windows Host, using WSL2 integration.

So, the enviroment:

1- Host: Windows 10 Professional.

2- Docker v19.03

The command to run the docker:

docker run \
    -i \
    --name mysqlbase \
    -e "MYSQL_ROOT_PASSWORD=s3cret" \
    -p 3306:3306 \
    -v $(pwd)/data:/var/lib/mysql \
    mysql:8.0

In the directoty /data the directories and files are created:

MySQL Files

And the result the execution:

Initializing database
mysqld: Cannot change permissions of the file 'ca.pem' (OS errno 1 - Operation not permitted)
2020-11-11T23:29:03.663345Z 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.
2020-11-11T23:29:03.663764Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.16) initializing of server in progress as process 30
2020-11-11T23:29:03.670814Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2020-11-11T23:29:03.671189Z 0 [Warning] [MY-010122] [Server] One can only use the --user switch if running as root
2020-11-11T23:29:19.833339Z 0 [ERROR] [MY-010295] [Server] Could not set file permission for ca.pem
2020-11-11T23:29:19.833377Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /var/lib/mysql/ is unusable. You can safely remove it.
2020-11-11T23:29:19.833522Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-11-11T23:29:22.394972Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.16)  MySQL Community Server - GPL.

The problem: Newly created data directory /var/lib/mysql/ is unusable

Using MySQL:5.6 works like a charm... but i need 8.

Update: I suspect something with the mysql user who must have ownership of the directory. I've already tried creating a mysql user on Windows, got its uid, and modified the Dockerfile (https://github.com/docker-library/mysql/blob/1a25a09159a3d7b6b5b8ad0e6c7eb53504b3aab5/8.0/Dockerfile) so that when it creates the image it assigns the same uid to it, but it doesn't work. The 16342 correspond the Windows user's id.

RUN groupadd -r mysql && useradd -u 16342 -r -g mysql mysql

I've read all question about that... but nothing work... any ideas?

Thanks in advance

1
  • Questions about development environments are off topic, but the problem is obviously that on the Windows filesystem permissions work differently. The problem is not the owner, it's the permissions on that file. You can try to create a docker volume and provide it to the container instead of an actual directory on the filesystem. Nov 12, 2020 at 6:49

1 Answer 1

2

Instead of mounting a local directory as a volume, try to use a docker-managed named volume.

The big difference is that this volume won't be subject to the limitations of windows file systems, which seems to be what's causing the issue here.

When using docker for a development database, this is generally what you want, since it keeps volume data well out of the way and doesn't mess with the local directory at all.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .