This page contains useful code snippets, Knowledge, and troubleshooting for SQL-type databases.
Docker: Migrate Bitnami/Mariadb to Mariadb
*Note: This process requires that you are using docker.
Bitnami is a provider of prepackaged open-source software and we use a good number of their docker images. Sometimes, you may require something different for whatever reason (vague, yes.), We do not know the reason but you may want to switch your bitnami/mariadb
image to mariadb
.
bitnami/mariadb:latest
to mariadb:latest
(avoid using “latest”, this is just an example)dbdata:/bitnami/mariadb/data
to dbdata:/var/lib/mysql
/data
at the end of the bitnami/mariadb
container volume! if you do not do this you will have issues trying to migrate to Mariadb!/data
you will need to access the host that has the docker volume, and cd into it (ex. cd /var/lib/docker/volumes/dbdata/_data/data && cp * ..
) This command will not work for you because you must put in your container name. Also, rsync may be better than the cp command for file permissions and such. Be extremely careful if this is a production container. You may want to take a backup!/dbdata:/bitnami/mariadb
to /dbdata/data:/var/lib/mysql
3. Change your environmental variables from MARIADB_<env>
to MYSQL_<env>
(see compose below)
4. If you are using bind mounts you may need to change the user permissions on the host machine. (ex for changing to Mariadb. chown -R 999:999
) (ex for changing to Bitnami/Mariadb. chown -R 1001:1001 *
)
5. You may possibly have to change permissions with chmod -R 755 *
but do not do this unless you have issues and are troubleshooting! We do not want to change file permissions lightly!
6. Run mysql_upgrade just in case.
mysql_upgrade - p
and enter your DB password. if this does not work then run mysql_upgrade -u <USER> -p
<USER> being the root user or regular user of your container, then enter your DB password.Here is an example compose of bitnami/mariadb
:
version: "3.8"
services:
db:
image: bitnami/mariadb:10.8
networks:
- internal
environment:
MARIADB_ROOT_PASSWORD: rootpass
MARIADB_DATABASE: db
MARIADB_USER: user
MARIADB_PASSWORD: pass
volumes:
- dbdata:/bitnami/mariadb/data
volumes:
dbdata:
networks:
internal:
external: false
Here is an example compose of mariadb
version: "3.8"
services:
db:
image: mariadb:10.8
networks:
- internal
environment:
MYSQL_ROOT_PASSWORD: rootpass
MYSQL_DATABASE: db
MYSQL_USER: user
MYSQL_PASSWORD: pass
volumes:
- dbdata:/var/lib/mysql
volumes:
dbdata:
networks:
internal:
external: false
run mysql_upgrade -p
and enter your DB password. if this does not work then run mysql_upgrade -u <USER> -p
<USER> being the root user or regular user of your database, then enter your DB password.