I have created MySql container in kubernetes Pod by using YAML deployment file. I am able to execute the mysql queries on that container and created few databases and tables with data in it. But when I make some changes in other code of project not related to kubernetes files and deployed it. On the recreation of pod all my previous databases are deleted from MySql container. I have also given mount path to mount the PVC to my container.
So my question is how to store the databases permanently so that on recreation of pod it will not delete the database and able to access that databases through newly created pod
Is PVC mounted on the MySQL data directory like /var/libe/mysql or If you are having different data directory, Use appropriate mount path for PVC where mysql stores data. You can find the sample spec for mysql deployment here