title: Running mysql commands with Kubectl
body: <p>I have <strong>mariadb-gallera</strong> deployed on my Kubernetes cluster and once the pod is deployed and it is up and running I want to get into the pod and login to mysql as root and after that create a database if it is not present over there.</p>
  <p>I tried to do so but it fails with errors:</p>
  <pre><code> name: &quot;Run command on every Pod labelled app=glaera&quot;
   command: &gt;
     kubectl exec -i &quot;{{ item }}&quot; --namespace backend -- mysql -u'root' -p'YWRtaW4xMjM=' -- 'CREATE DATABASE IF NOT EXISTS aves';
   with_items: &quot;{{ pod_names }}&quot;
  </code></pre>
  <p>Please help me with a solution.</p>
  <p>Error:</p>
  <pre><code>failed: [localhost] (item=galera-mariadb-galera-0) =&gt; {&quot;ansible_loop_var&quot;: &quot;item&quot;, &quot;changed&quot;: true, &quot;cmd&quot;: [&quot;kubectl&quot;, &quot;exec&quot;, &quot;-i&quot;, &quot;galera-mariadb-galera-0&quot;, &quot;--namespace&quot;, &quot;backend&quot;, &quot;--&quot;, &quot;mysql&quot;, &quot;-uroot&quot;, &quot;-pYWRtaW4xMjM=&quot;, &quot;--&quot;, &quot;CREATE DATABASE IF NOT EXISTS aves;&quot;], &quot;delta&quot;: &quot;0:00:00.190892&quot;, &quot;end&quot;: &quot;2021-02-02 11:57:37.806727&quot;, &quot;item&quot;: &quot;galera-mariadb-galera-0&quot;, &quot;msg&quot;: &quot;non-zero return code&quot;, &quot;rc&quot;: 1, &quot;start&quot;: &quot;2021-02-02 11:57:37.615835&quot;, &quot;stderr&quot;: &quot;ERROR 1049 (42000): Unknown database 'CREATE DATABASE IF NOT EXISTS aves;'\ncommand terminated with exit code 1&quot;, &quot;stderr_lines&quot;: [&quot;ERROR 1049 (42000): Unknown database 'CREATE DATABASE IF NOT EXISTS aves;'&quot;, &quot;command terminated with exit code 1&quot;], &quot;stdout&quot;: &quot;&quot;, &quot;stdout_lines&quot;: []}
  </code></pre>