title: How do I restore a dump file from mysqldump using kubernetes?
body: <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>