rpi4 + kodi + docker + nextcloud + mariadb

  • I've got a brand new 4GB RPi4 with LibreElec 9.1.002 / Kodi v18.3 running. Now I'm trying to get Nextcloud working so I installed the linuxserver.io AddOn packges that supply Docker, NextCloud and MariaDB (or should I use tha MariaDB package from the LibreElec team which failed to install?)

    Installation is not the problem all seems to work. I can see that MariaDB is running and when browsing to 192.168.2.18 Nextcloud shows the webpage that is supposed to create the admin account and select the type of database and database user.

    Whatever I try I always get the error message below:

    Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory

    I have specified localhost:3306 and chosen some credentials. I've also tried to create these credentials by hand using the MariaDB docker instance.

    e.g.:

    create database nextcloud;

    create user nextcloud@localhost identified by 'xxxxx';

      grant all privileges on nextcloud.* to nextcloud@localhost identified by 'xxxxx';

    flush privileges;

    What is the proper way to get this working?

    PS: from https://forum.libreelec.tv

    Quote

    You will need the root database login, or any administrator login , and then enter any name you want for your Nextcloud database. Be careful your administrator login needs to have the permissions to create and modify databases and he needs to have the permissions to grant permissions to other users.

    After you enter your root or administrator login for your database, the installer creates a special database user with privileges limited to the Nextcloud database. Then Nextcloud needs only the special Nextcloud database user, and drops the root dB login. This user is named for your Nextcloud admin user, with an oc_ prefix, and then given a random password. The Nextcloud database user and password are written into config.php:

  • For docker containers, don't use localhost. Use the server IP.

    If both mariadb and nextcloud are linuxserver addons, then in nextcloud you can simply use "mariadb" as the mysql address and port 3306. The containers can connect to each other directly via docker network by using their container names or aliases set

  • aptalca

    Aha that is very useful info.Thanks! Just tried it but now the error messages changed:

    Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user 'nextcloud'@'docker.linuxserver.nextcloud.lsio' (using password: YES)

    I used: mariadb:3306 as database host.

    Perhaps I should try and create the nextcloud user by hand? (like I tried before)

    So this is what I did:

    • switched to mariadb cocker instance (exec bash)
    • created the nextcloud database with user 'nextcloud'@'docker.linuxserver.nextcloud.lsio'
    • then gave the user the permissions needed (see initial post)
    • subsequently entered details in nextcloud initial page
    • used mariadbL3306 as host and port

    Et voila! It worked!

    Thanks!

  • Glad to hear it worked. For future reference (and for other users), you could have just used user root and the password you set in the mariadb addon settings in nextcloud. No need to exec in, manually creating a user and messing with permissions