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?
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.
Most helpful comment
Thanks @mwmllr, your comment about the mysql ip as a root user helped me to solve my problem.