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
    1. docker images
    2. REPOSITORY TAG IMAGE ID CREATED SIZE
    3. lsioarmhf/mariadb latest f0864d82e9d0 2 days ago 295MB
    4. lsioarmhf/nextcloud latest 0dc0bbe74775 2 days ago 159MB


    then:


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


    next:


    Code
    1. docker exec -it docker.linuxserver.mariadb bash
    2. [email protected]:/#


    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
    1. CREATE DATABASE ncdb;
    2. 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.

  • docker exec -it docker.linuxserver.mariadb bash

    mysql -u root -p

    CREATE USER 'kodi' IDENTIFIED BY 'kodi';

    GRANT ALL ON *.* TO 'kodi';

  • Code
    1. docker exec -it docker.linuxserver.mariadb bash
    2. mysql -u root -p
    3. Enter password:
    4. 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

  • 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.

  • Ok thanks.


    I'll try starting from scratch.


    On the bright side: If it was a one button install, I wouldn't have learnt anything ;)