I am trying to create mysql container at mount path /var/lib/mysql in kubernetes, but when I deploy, I get the following error.
2022-12-16T07:13:59.139528Z 0 [Error] [MY-010457] [Server] --initialize was specified but there were files in the data directory. Aborting.
2022-12-16T07:13:59.139537Z 0 [Error] [MY-013236] [Server] The specified data directory /var/lib/mysql/ is not available. You can delete all files added to it by the server.
How to fix this error. I want to create a MySql container and store the database in some folder so that on new deployment I can get the old data.
Your directory is not empty. You must delete everything there or choose something else.
The error message "The newly created data directory /var/lib/mysql/ is not available" appears due to size issues. Check/increase the underlying server size or the docker size allocated for the system.
You can also create a docker container from the command line, populate the empty data directory with MySQL initialization, and then use docker-compose. When the data directory has been initialized, no error occurs.
Also check out the GitHub link and Stackpost.