I need some help with the mariadb module. I want to test it, so I uploaded some databases to the ./home/mariadb1/.local/share/containers/storage/volumes/mysql-data/_data directory with scp for testing purposes. I set the owner of the uploaded directories and files to match the owner in the directory (428678:428678). I created a user for the uploaded files and assigned them to them in phpmyadmin.
However, in phpmyadmin I cannot see or access the tables of the uploaded databases, it is as if there are no tables in them. However, listing the directories shows the files… What could be the problem?
Define correct permissions for directories (755) and files (644)
sudo find /home/mariadb1/.local/share/containers/storage/volumes/mysql-data/_data -type d -exec chmod 755 {} ;
sudo find /home/mariadb1/.local/share/containers/storage/volumes/mysql-data/_data -type f -exec chmod 644 {} ;
If you use a Podman container
sudo podman restart <container_name>
sudo systemctl restart married
Copying the files directly to the data directory is the main cause of this type of problem. The InnoDB storage engine, which is the default in MariaDB, uses a central file called ibdata1 to manage the metadata of the tables. If you did not copy that file along with the others, MariaDB does not have the necessary information to view your tables.
The safe and recommended way to migrate a database is by using the mysqldump tool. This process exports the database to a text file (.sql) and then imports it, ensuring that all data and metadata are transferred correctly without risk of corruption.
@jgjimenezs Thanks for the advice but the problem is that NS8 doesn’t know the mysql and mysqldump commands. I get the “Command not found” error message…
Thank you @mrmarkuz , I forgot about the container bash, so it’s now available and I have the root password. Now I just need to update my script for reloading the databases…
Unfortunately, this shortcut only allows you to copy one file, I would like to load more. I previously created a script for backing up and restoring databases, which creates a sql file for each database. The database files must be uploaded either with a directory or compressed as a single file.
You can only upload it to the host with scp, not to the container. Therefore, it could be uploaded to the /home/mariadb1 directory, which is already accessible from the mariadb-app container. The podman cp command can only copy files one by one by default, but it was possible to copy a directory as well.
Unfortunately, the mariadb container doesn’t have vim, so I can’t edit the database restore script or create it in the container, only on the host. So I uploaded it to the /home/mariadb1 directory and edited it, so it was accessible from the container as well. Running it restored all database files that were accessible via VPN.
You could scp to /home/mariadb1/.local/share/containers/storage/volumes/mysql-data/_data/ so the files will be located in the mariadb-app container under /var/lib/mysql
Thank you @mrmarkuz I finally solved the problem in a similar way.
Unfortunately, I may have messed something up because yum wouldn’t run in the container. Programs installed in a container are usually deleted when the container is restarted, so I didn’t want to bother with it and looked for another solution.
I started with this but either there was a problem with the backup or with the upload, but the copied libraries were incomplete, the tables disappeared from the databases. Unfortunately, I couldn’t set the owner either because I don’t know what 428678 numeric ownership and group could be. I set it numerically, but that wasn’t the reason for the tables disappearing. That’s why I had to make a backup with mysqldump and load it.