nextcloud and mariadb (both) on docker: SQLSTATE[HY000] [2002] No such file or directory
Solution 1
Just for curiousity I started playing around with the localhost-port. I chose 3307 because my host-system has a mariadb running on 3306, which I do not want to use. So altering port localhost:3307
to localhost:WXYZ
- you name it gives the same error... mmmh - changeing localhost
to <your host-IP>
!!!
SUCCESS
Solution 2
I had to use nextcloud-mariadb:3306
as the connection string. I figured it out by running $ docker ps -a
which lists the name and the port.
Solution 3
I changed localhost
-> mariadb
and it worked!
Related videos on Youtube
akrea
Updated on June 04, 2022Comments
-
akrea almost 2 years
I've been trying to set up nextlcoud and mariadb with the linuxserver images and hit my road block when I want to get through the first run wizard of nextcloud: Error message incl. all settings of first run wizard
Problem
I.e. the first time wizard gives me
Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory
.Question:
Where is that coming from and how to solve the problem?
System
I'm using Amahi 11 and have installed docker from the repositories. Docker verision:
Client: Version: 18.09.0 API version: 1.39 Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:48:52 2018 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.0 API version: 1.39 (minimum version 1.12) Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:19:08 2018 OS/Arch: linux/amd64 Experimental: false
I am starting nextcloud and mariadb with docker-compose. Following the content for mariadb:
version: '2' services: mariadb: image: linuxserver/mariadb container_name: mariadb environment: - PUID=XX - PGID=YYY - MYSQL_ROOT_USER=root - MYSQL_ROOT_PASSWORD=secret - MYSQL_DATABASE=nextcloud volumes: - <path/to/my/folder>:/config ports: - 3307:3306 restart: unless-stopped
Already tried:
- A lot of research, which came up empty or lead me to do the next point:
- So from the error info I started checking if the database actually exists:
sudo docker exec -it mariadb bash
. There I figured, that access to command-line with 'mysql' for root was denied because the password was not set. (mmmh... is ther something wrong with my docker-compose-file?) Anyway I corrected that one withmysql -u root -pSECRET
andmysql -u root --password=SECRET
. Withshow databases;
I found nonextcloud
database. (There MUST be something wrong with my docker-compose-file.) So I created it as well (create database nextcloud;
). Database is now shown properly and I found it in<path/to/my/folder>
. Result: No change, problem still there. -
I did some more editing with on my docker-compose-file:
version: '2' services: mariadb: image: linuxserver/mariadb container_name: mariadb environment: - MYSQL_ROOT_PASSWORD=secret - MYSQL_DATABASE=nextcloud - PUID=XX - PGID=YYY volumes: - <path/to/my/folder>:/config ports: - 3307:3306 restart: unless-stopped
So I changed the hierarchy and eliminated the
MYSQL_ROOT_USER=root
line. When restarting I canmysql -u root --password=SECRET
and show thenextcloud
database. YET, I am not sure, if these changes remained in the volume from my last (manual) changes. Result: Problem still there.
-
Jsowa over 3 yearsDoes this answer your question? Using Docker I get the error: "SQLSTATE[HY000] [2002] No such file or directory"