<p>I know <a href="https://stackoverflow.com/q/105776/232794">how to restore a dump file from mysqldump</a>. Now, I am attempting to do that using kubernetes and a docker container. The database files are in persistent (nfs) mount. The docker cannot be accessed outside of the cluster as there is no need for anything external to touch it. </p>

<p>I tried:</p>

<pre><code>kubectl run -i -t dbtest --image=mariadb --restart=Never --rm=true --command -- mysql -uroot -ps3kr37 &lt; dump.sql
</code></pre>

<p>and </p>

<pre><code>kubectl exec mariadb-deployment-3614069618-mn524 -i -t -- mysql -u root -p=s3kr37 &lt; dump.sql
</code></pre>

<p>But neither commands worked -- errors about TTY, sockets, and other things hinting that I am missing something vital here.</p>

<p><em>What am I not understanding here?</em></p>

<p>I <em>could</em> just stop the deployment, scp the database files, and restart the container and hope for the best. However, what can go right?</p>

<hr>

<p>The question <a href="https://stackoverflow.com/q/40925822/232794">Install an sql dump file to a docker container with mariaDB</a> sure looks like a duplicate but is not: first, I am on Linux not Windows and more importantly the answers all are about initialising with a dump. I want to be able to trash the data and revert to the dump data. This is a test system that will eventually be the "live" so I need to restore from many potential dumps.</p>

<p>As described in <a href="https://medium.com/@madushagunasekara/export-mysql-db-dump-from-kubernetes-pod-and-restore-mysql-db-on-kubernetes-pod-6f4ecc6b5a64" rel="noreferrer">here</a> you can use the following command to restore a DB on kubernetes pod from a dump in your machine</p>

<pre><code>$ kubectl exec -it {{podName}} -n {{namespace}} -- mysql -u {{dbUser}} -p{{password}} {{DatabaseName}} &lt; &lt;scriptName&gt;.sql
Example :
$ kubectl exec -it mysql-58 -n sql -- mysql -u root -proot USERS &lt; dump_all.sql
</code></pre>
