title: MySql's 'CREATE DATABASE IF NOT EXISTS' misbehaves when database has live connections
body: <p>We have some initialization code that makes sure that all the needed resources are in place,<br>
  i.e.: creates those resources (files, directories, databases, tables, etc.) if missing, and does nothing otherwise.</p>
  
  <p>But, when a database is in use (i.e. exists and already has live connections), a new app
  that goes through the initialization code waits forever.  </p>
  
  <p>The reason is that 'CREATE DATABASE IF NOT EXISTS' is kinda stupid: it tries to own the database, even though it exists and nothing should be done.  </p>
  
  <p>Is there a way to check whether a database already exists, that does not involve such a lock?</p>