title: nextcloud and mariadb (both) on docker: SQLSTATE[HY000] [2002] No such file or directory
body: <p>I've been trying to set up <a href="https://hub.docker.com/r/linuxserver/nextcloud/" rel="nofollow noreferrer">nextlcoud</a> and <a href="https://hub.docker.com/r/linuxserver/mariadb/" rel="nofollow noreferrer">mariadb</a> with the linuxserver images and hit my road block when I want to get through the first run wizard of nextcloud:
  <a href="https://i.stack.imgur.com/CAh79.png" rel="nofollow noreferrer">Error message incl. all settings of first run wizard</a></p>
  
  <h2>Problem</h2>
  
  <p>I.e. the first time wizard gives me <code>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</code>.</p>
  
  <h2>Question:</h2>
  
  <p>Where is that coming from and how to solve the problem?</p>
  
  <h2>System</h2>
  
  <p>I'm using <a href="https://wiki.amahi.org/index.php/Amahi_11_Install" rel="nofollow noreferrer">Amahi 11</a> and have installed docker from the repositories. Docker verision:</p>
  
  <pre><code>  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
  </code></pre>
  
  <p>I am starting nextcloud and mariadb with docker-compose. Following the content for mariadb:</p>
  
  <pre><code>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:
          - &lt;path/to/my/folder&gt;:/config
        ports:
          - 3307:3306
        restart: unless-stopped
  </code></pre>
  
  <h2>Already tried:</h2>
  
  <ol>
  <li>A lot of research, which came up empty or lead me to do the next point:</li>
  <li>So from the error info I started checking if the database actually exists:<code>sudo docker exec -it mariadb bash</code>. 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 <code>mysql -u root -pSECRET</code>and <code>mysql -u root --password=SECRET</code>. With <code>show databases;</code> I found no <code>nextcloud</code> database. (There MUST be something wrong with my docker-compose-file.) So I created it as well (<code>create database nextcloud;</code>). Database is now shown properly and I found it in <code>&lt;path/to/my/folder&gt;</code>. <strong>Result:</strong> No change, problem still there.</li>
  <li><p>I did some more editing with on my docker-compose-file:</p>
  
  <pre><code>version: '2'
    services:
      mariadb:
        image: linuxserver/mariadb
        container_name: mariadb
        environment:
          - MYSQL_ROOT_PASSWORD=secret
          - MYSQL_DATABASE=nextcloud
          - PUID=XX
          - PGID=YYY
        volumes:
          - &lt;path/to/my/folder&gt;:/config
        ports:
          - 3307:3306
        restart: unless-stopped
  </code></pre>
  
  <p>So I changed the hierarchy and eliminated the <code>MYSQL_ROOT_USER=root</code>line. When restarting I can <code>mysql -u root --password=SECRET</code> and show the <code>nextcloud</code> database. YET, I am not sure, if these changes remained in the volume from my last (manual) changes. <strong>Result:</strong> Problem still there.</p></li>
  </ol>