title: Can I switch the 'connected' user within an sql script that is sourced by mysql?
body: <p>I was wondering if I can switch the "connected" user within an sql script that is executed by <code>mysql</code>.</p>
  
  <p>Here's a description of my goal. Perhaps, it's not necessary to swich the user and another solution gives me what I want.</p>
  
  <p>I want to write a <em>database creation script</em> like so:</p>
  
  <pre><code>create databse some_db;
  
  create user u@localhost identified by 'pw';
  
  grant all on u.* to u;
  
  -- Here's where I want to switch the user, but *obviously* the 
  -- following command fails
  
  connect u@localhost/pw;
  
  -- Now, as new user, create the tables:
  
  use some_db;
  
  create table t (...
  </code></pre>
  
  <p>This script would then be called from the command line like</p>
  
  <pre><code>$ mysql -u root -p"....." &lt; create_db.sql
  </code></pre>
  
  <p>Is this possible or do I have to leave the script in order to switch the connected user?</p>