title: Run MySQL query on command line from a script
body: <p>How can i run a mysql query from a script via the ubuntu command line using the mysql client? I know i can use the following command:</p>
  
  <pre><code>mysql -uroot -psecret -e "select * ..."
  </code></pre>
  
  <p>But my query is too big and would like to be read from a script instead. I tried the following and did not work:</p>
  
  <pre><code>mysql -uroot -psecret &lt; /path/to/script.sql
  </code></pre>
  
  <p>i get the error:</p>
  
  <pre><code>ERROR 1046 (3D000) at line 1: No database selected
  </code></pre>