title: MySQL Error 1046: No database selected
body: <p>I've created my first database for a lab, and when I try to run it in MySQL, I keep getting the same 1046 error: No database selected.</p>
  
  <p>First, I run source (scriptfilename).sql and get:</p>
  
  <pre><code>MariaDB [(none)]&gt; source McClureLab1.sql;
  ERROR 1046 (3D000) at line 1 in file: 'McClureLab1.sql': No database selected
  ERROR 1046 (3D000) at line 5 in file: 'McClureLab1.sql': No database selected
  ERROR 1046 (3D000) at line 12 in file: 'McClureLab1.sql': No database selected
  ERROR 1046 (3D000) at line 18 in file: 'McClureLab1.sql': No database selected
  +-----------------------------+
  | @lastID := LAST_INSERT_ID() |
  +-----------------------------+
  |                           0 |
  +-----------------------------+
  1 row in set (0.00 sec)
  
  ERROR 1046 (3D000) at line 21 in file: 'McClureLab1.sql': No database selected
  ERROR 1046 (3D000) at line 23 in file: 'McClureLab1.sql': No database selected
  +-----------------------------+
  | @lastID := LAST_INSERT_ID() |
  +-----------------------------+
  |                           0 |
  +-----------------------------+
  1 row in set (0.00 sec)
  
  ERROR 1046 (3D000) at line 26 in file: 'McClureLab1.sql': No database selected
  ERROR 1046 (3D000) at line 28 in file: 'McClureLab1.sql': No database selected
  </code></pre>
  
  <p>The same thing happens when I try to show my tables:</p>
  
  <pre><code>ERROR 1046 (3D000): No database selected
  </code></pre>
  
  <p>I'm not sure if there is something wrong with the database I've created, or if I'm entering commands incorrectly in MySQL.</p>