Closed netwrkx closed 5 years ago
Your sql dump is of a single database, it has no use ubox2
statement in it so the statements essentially go nowhere.
There are different ways to dump sql but using mysqldump --databases test > dump.sql
will include create and use stanzas in the dump and will work based on the database name passed test
in this case.
Also as far as building a local docker image to include files that is not how you use the custom files. Your compose file arbitrarily mounts your PWD while we specifically state all data is stored in /config in both the command examples and the example of how to load custom sql on boot.
You want to bind mount a folder that already has a initdb.d/
folder in it with sql files to config ie:
/home/myuser/mariadata:/config
Where mariadata has an initdb.d folder in it.
I am going to close this issue but you can still ping me here if you are having problems with anything I explained.
@thelamer thanks for your response but what other ways can I export my database in this scenario
I have not used phpmyadmin in some time , but I remember there being a bunch of options for data and structure when creating a dump there should be options to include creates and use stanzas not sure their option names in the web ui though.
@thelamer i've added the following to my sql file, is there any other thing i supposed to add
CREATE DATABASE IF NOT EXISTS `ubox2` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
USE `ubox2`;
@thelamer i've updated my docker-compose file as follow mariadata contains initdb.d which also contains ubox2.sql
dockerfile
# ---- Base Node ----
FROM linuxserver/mariadb
docker-compose.yaml
version: '3'
services:
mariadb:
build:
context: ./db
dockerfile: mariadb.Dockerfile
container_name: db-mariadb
restart: unless-stopped
ports:
- "3306:3306"
environment:
TZ: Europe/London
MYSQL_USER: jukebox
MYSQL_DATABASE: ubox2
MYSQL_PASSWORD: QoX12mvf
MYSQL_ROOT_PASSWORD: B9lleTTy
volumes:
- /home/node_project/db/mariadata:/config
networks:
- app-network
root@DietPi:/home/node_project# docker logs db-mariadb
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-adduser: executing...
usermod: no changes
-------------------------------------
_ ()
| | ___ _ __
| | / __| | | / \
| | \__ \ | | | () |
|_| |___/ |_| \__/
Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------
User uid: 911
User gid: 911
-------------------------------------
[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 30-config: executing...
[cont-init.d] 30-config: exited 0.
[cont-init.d] 40-initialise-db: executing...
[cont-init.d] 40-initialise-db: exited 0.
[cont-init.d] 99-custom-scripts: executing...
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-scripts: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
191029 19:29:53 mysqld_safe Logging to syslog.
191029 19:29:53 mysqld_safe Starting mysqld daemon with databases from /config/databases
root@DietPi:/home/node_project# docker exec -it db-mariadb mysql -ujukebox -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.1.41-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ubox2 |
+--------------------+
2 rows in set (0.01 sec)
MariaDB [(none)]> use ubox2
Database changed
MariaDB [ubox2]> show tables;
Empty set (0.00 sec)
MariaDB [ubox2]>
MariaDB [ubox2]> exit
Bye
root@DietPi:/home/node_project# docker exec -it db-mariadb /bin/sh
# ls
app bin boot config defaults dev docker-mods etc home init lib libexec media mnt opt proc root run sbin srv sys tmp usr var
# cd onfig
/bin/sh: 2: cd: can't cd to onfig
# cd config
# ls
custom.cnf databases initdb.d log
# cd initdb.d
# ls
ubox2.sql
#
The problem you are running into now is the DB is already started and populated as it sees it, none of the init logic runs if mysql folderexists in the config folder the specific check for all the init logic is this: https://github.com/linuxserver/docker-mariadb/blob/master/root/etc/cont-init.d/40-initialise-db#L16
You would need a clean /config folder with just the initdb.d folder in it for it to bootstrap again.
@thelamer i've clear my config folder leaving only initdb.d, in initdb.d is my ubox2.sql. database ubox2 was created but its empty, no table or data below is the latest log
root@DietPi:/home/node_project# docker logs db-mariadb
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-adduser: executing...
usermod: no changes
-------------------------------------
_ ()
| | ___ _ __
| | / __| | | / \
| | \__ \ | | | () |
|_| |___/ |_| \__/
Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------
User uid: 911
User gid: 911
-------------------------------------
[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 30-config: executing...
[cont-init.d] 30-config: exited 0.
[cont-init.d] 40-initialise-db: executing...
Setting Up Initial Databases
Installing MariaDB/MySQL system tables in '/config/databases' ...
2019-10-29 21:03:09 1995664192 [Note] /usr/sbin/mysqld (mysqld 10.1.41-MariaDB-0ubuntu0.18.04.1) starting as process 263 ...
OK
Filling help tables...
2019-10-29 21:03:28 1996348224 [Note] /usr/sbin/mysqld (mysqld 10.1.41-MariaDB-0ubuntu0.18.04.1) starting as process 292 ...
OK
Creating OpenGIS required SP-s...
2019-10-29 21:03:32 1995901760 [Note] /usr/sbin/mysqld (mysqld 10.1.41-MariaDB-0ubuntu0.18.04.1) starting as process 322 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h a54d1e35c4ef password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
You can start the MariaDB daemon with:
cd '/usr' ; /usr/bin/mysqld_safe --datadir='/config/databases'
You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mysql-test-run.pl
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
2019-10-29 21:03:36 1996254016 [Note] mysqld (mysqld 10.1.41-MariaDB-0ubuntu0.18.04.1) starting as process 350 ...
Database Setup Completed
[cont-init.d] 40-initialise-db: exited 0.
[cont-init.d] 99-custom-scripts: executing...
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-scripts: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
191029 21:03:41 mysqld_safe Logging to syslog.
191029 21:03:41 mysqld_safe Starting mysqld daemon with databases from /config/databases
root@DietPi:/home/node_project#
root@DietPi:/home/node_project#
root@DietPi:/home/node_project# docker exec -it db-mariadb /bin/sh
# cd /config/initdb.d
# ls
ubox2.sql
#
#
# mysql -ujukebox -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.1.41-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ubox2 |
+--------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]> use ubox2
Database changed
MariaDB [ubox2]> show tables;
Empty set (0.00 sec)
MariaDB [ubox2]>
what am i missing
If you have use before the table creates than it should just be working please pastebin the full SQL file so I can test it locally
looks like your issue is here: https://jira.mariadb.org/browse/MDEV-20912
ERROR 1273 (HY000): Unknown collation: 'utf8mb4_0900_ai_ci'
Looks like some kind of regression as this was an old character set introduced in MySQL 5.7. you can dump in like mysql 4.0 compatibility mode to just use UTF8. (under format specific options)
@thelamer thanks, finally resolved it. i had to manually replace utf8mb4_0900_ai_ci with utf8_general_ci replace utf8mb4 with utf8
switching to mysql4.0 compatibility mode didnt help. thanks
If you are new to Docker or this application our issue tracker is ONLY used for reporting bugs or requesting features. Please use our discord server for general support.
Expected Behavior
Load custom sql files on init
Current Behavior
custom sql files wont load
Steps to Reproduce
DOCKER-COMPOSE.YAML
Environment
*OS:RASPBERRY 3+*
Command used to create docker container (run/create/compose/screenshot)
Docker logs