Docker: How to configure Mariadb?

  • Firstly, I am a real beginner so please be kind.

    My goal is to run KODI + Samba (LibreElec) and nextcloud on a single Pi which has an 8tb USB RAID1 enclosure connected to it. Maybe the Pi doesn't have enough power to do both these tasks, but energy efficiency is my goal over performance, so I want to at least try.

    I used a test microSD card with libreElec, made sure KODI and SMB works, everything good.

    Then I installed docker, and read a ton about what docker is and how it works. I get it, all good.

    I install the docker repo in KODI and then install a nextcloud container. Surprisingly, this seems to install with no fuss.

    Then I see a warning about using a lite db and see a preferred option to use Mariadb, which I saw when I was browsing through the docker repo. So I install Mariadb and set a config for port mapping, folder mapping and password.

    And that was where I get past the point of winging it and need some assistance.

    SSH in as root then:

    Code
    docker images
    REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
    lsioarmhf/mariadb     latest              f0864d82e9d0        2 days ago          295MB
    lsioarmhf/nextcloud   latest              0dc0bbe74775        2 days ago          159MB

    then:

    Code
    docker ps
    CONTAINER ID        IMAGE                        COMMAND             CREATED             STATUS              PORTS                          NAMES
    a0120c73dc4a        lsioarmhf/nextcloud:latest   "/init"             25 hours ago        Up 25 hours         80/tcp, 0.0.0.0:443->443/tcp   docker.linuxserver.nextcloud
    3049a08c04a6        lsioarmhf/mariadb:latest     "/init"             25 hours ago        Up 25 hours         0.0.0.0:3306->3306/tcp         docker.linuxserver.mariadb

    next:

    Code
    docker exec -it docker.linuxserver.mariadb bash
    root@3049a08c04a6:/#

    so now, IIUC, I am 'inside' the mariadb container.

    And this is where I am stuck. I know I need to create a database, but I am unclear how. There seems to be some extremely basic step I'm missing, as when I try:

    Code
    CREATE DATABASE ncdb;
    bash: CREATE: command not found

    Obviously I am still in BASH and not in mysql, but I'm lost with the next step, despite reading:

    A MariaDB Primer - MariaDB Knowledge Base

    and


    CREATE DATABASE - MariaDB Knowledge Base

    I've really tried to learn this on my own, but I need a little pointer in the right direction. So far this community has been awesome.

  • Code
    docker exec -it docker.linuxserver.mariadb bash
    mysql -u root -p
    Enter password:
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

    I'm getting the above error and I don't understand why

    Edited once, last by jimmygolitely (November 19, 2018 at 9:38 PM).

  • The file /var/run/mysqld/mysqld.sock did not exist.

    Manually create it by entering touch /var/run/mysqld/mysqld.sock


    Change ownership by entering chown mysql /var/run/mysqld/mysqld.sock.

    Restart the MySQL service by entering service mysql restart or /etc/init.d/mysql restart.

    Now I get '111 connection refused'.

    I'm certain I'm using the same password I entered in the KODI GUI when I installed the container.

    Is all this normal, or should I nuke the whole thing and start again? I haven't seen any of these steps mentioned in any tutorials I've read.

  • I've asked one of the linuxserver.io folks to look at doing a one-button install for the MariaDB container add-on, i.e. create a kodi database and set the base kodi/kodi user/pass with necessary rights on the tables.