Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nextcloud and mariadb (both) on docker: SQLSTATE[HY000] [2002] No such file or directory

I've been trying to set up Nextcloud and MariaDB with the Linux server 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:

  1. A lot of research, which came up empty or lead me to do the next point:

  2. 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 with mysql -u root -pSECRETand mysql -u root --password=SECRET. With show databases; I found no nextcloud 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.

  3. 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=rootline. When restarting I can mysql -u root --password=SECRET and show the nextcloud database. YET, I am not sure, if these changes remained in the volume from my last (manual) changes. Result: Problem still there.

like image 327
akrea Avatar asked Oct 25 '25 16:10

akrea


1 Answers

I changed localhost -> mariadb and it worked!

like image 124
HoangDoan Avatar answered Oct 28 '25 06:10

HoangDoan