Mysql initializing databsase error -- initialize specified but the data directory has files in it

Hi! I am currently using xwiki via a docker-compose installation (1 tomcat container + 1 mysql data container). My installation ran fine until I decided to to move the mysql-data volume (attached to the mysql data container) from /var/lib/docker/volumes to another place. To do so, I stopped my containers (docker-compose down), then I updated the docker-compose file to specify my new sql data volume path:

a part of my docker-compose file ->

volumes:
- /my/path/xwiki-data-mysql_backup/xwiki-mysql-data:/var/lib/mysql

And after having restarted xwiki (docker-compose up), I get the following error, making the mysql data container restarting again and again
“mysql initializing databsase error – initialize specified but the data directory has files in it.”

Any suggestions?

++++

Hi, I’ve never done this so I don’t know (it also doesn’t seem related to xwiki). Maybe you could try asking the maintainers of the MySQL docker image? Or ask on the MySQL forums maybe?

Have you tried to google too?

Just did a quick googling and the first entry is https://github.com/docker-library/mysql/issues/290

I finally found how to fix it. Data are normally stored in /var/lib/docker/volumes/xwiki_mysql-data/_data. If you want to move it to a specific directory (/my/path/to/xwiki_mysql-data/):

  • docker-compose down
  • update your docker-compose.yml file to replace all references to this volume by /my/path/to/xwiki_mysql-data/ (and remove the volume definition)
  • move /var/lib/docker/volumes/xwiki_mysql-data/_data/* to /my/path/to/xwiki_mysql-data/ (skip “_data” sub dir)
  • docker-compose up -d