Devilbox: Mounting to an existing MySQL database

Created on 5 Feb 2018  路  3Comments  路  Source: cytopia/devilbox

I had a general question regarding the database location, specifically MySQL. I'd like to use my existing database files. In the .env file it says

This can be an existing mysql data directory or empty.

If it already is a mysql data directory with content,

it will be mounted into the docker and used.

#

If this directory is empty, a new mysql database will be

created.

And also

Note: Inside this path, a subdirectory with the mysql|mariadb

version will be created where the actual data resides.

This is to protect databases from being altered by

newer or older mysql|mariadb server versions.

I point the HOST_PATH_MYSQL_DATADIR to the correct location, and devilbox creates a folder underneath that with the specific mysql version, with an empty database (or rather with the default

| information_schema |
| mysql |
| performance_schema |
| sys

)

This makes sense so far.

But how do I use my existing databases? I can dump them from the original location (e.g. /var/lib/mysql) and import them into this subfolder (e.g. /var/lib/mysql/mysql-5.7) each time I want to use devilbox with my current data. But is that the only way?

Most helpful comment

Thanks @mwmllr, your comment about the mysql ip as a root user helped me to solve my problem.

All 3 comments

So I guess the simplest way is to move the content from /var/lib/mysql/* to where you store the devilbox mysql data (e.g.: /home/mwmllr/devilbox/data/mysql/mysql-5.7). And then just symlink /home/mwmllr/devilbox/data/mysql/mysql-5.7 to /var/lib/mysql

I have now done this. I still need to resolve some problems with the symlink to the original db location - rsyncing is fine if I want to update. I also had to add 172.16.238.10 as a root user in the database. But it seems to be working. Thanks.

Thanks @mwmllr, your comment about the mysql ip as a root user helped me to solve my problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hurrtz picture hurrtz  路  5Comments

joshjacksoncastus picture joshjacksoncastus  路  3Comments

fkaminski picture fkaminski  路  4Comments

tmort picture tmort  路  7Comments

StanMenten99 picture StanMenten99  路  6Comments