Can't create or write into the data directory /usr/local/var/mysql

I have seen a number of solutions suggested for this error but none have worked for me. I think it is because the installations are slightly different from what I am doing.

Here is what I have going…

  • I am trying to install Nextcloud on a macOS machine using the Docker container.

  • I want to run the DB off of the local drive.

  • I have installed mariaDB and created a db and and db user for Nextcloud

  • I have set the folder privileges containing the db to allow the www user to read and write.

  • When running the setup wizard I get following error “Can’t create or write into the data directory /usr/local/var/mysql”.

I suspect this has something to do with trying to access the db outside of the container. I am not even sure running the db on the local drive is the best idea and maybe I should be running it from the container itself. If so, I can’t figure out how to do that either.

I have read a bunch of posts and looked the Nextcloud documentation. I am beginning to feel like a dunce. Any help is greatly appreciated.

I’m not an expert on docker installations of nextcloud, espacially not on macOS, but i guess that by standard nextcloud will try to use the database-service brought with the docker instance. I had a similar problem with another docker container once, where the two existing mysql installations were blocking each other access to some specific ports resulting in some unspecific error messages (that was ubuntu) and i had to kill the external process to allow the docker to function properly, but this is only speculation. Did you put any specific settings to tell NC to use the external DB or did you just install and run the docker?
To the issue of using a DB on an external drive: i do not really see the reason, as the DB itself does not get too large in data usage and is easy to backup, if data-loss is your main motivation. I also cannot imagine it would do much good for your system performance. Having the actual data on an external drive is another story and quite well supported.