title: PDO access denied for user 'username'@'%'
body: <p>I need to connect to a remote mysql server using a php page;<br>the connection itself works as a charm, but the moment i try to create the database, as it doesn't exist yet, i get this error:</p>
  <blockquote>
  <p>exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1044 Access denied for user '[myusername]'@'%' to database '[mydbname]'' in [myurl]/php/db_manager.php:76</p>
  </blockquote>
  <p>As you can see, i have access denied to &quot;%&quot;.<br>
  Now: what is &quot;%&quot;?</p>
  <p>Furthermore:<br></p>
  <h1>Main file</h1>
  <pre><code>private function createDB() {
  if($this-&gt;cm-&gt;update(&quot;CREATE DATABASE IF NOT EXISTS &quot; . $this-&gt;dbName . &quot; DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;&quot;, array())) { // Error here
    $this-&gt;cm-&gt;update(&quot;USE &quot; . $this-&gt;dbName . &quot;;&quot;, array());
    return true;
  }
  return false;
  }
  </code></pre>
  <p>$this-&gt;cm is an instance of a correctly initialized PDO wrapper</p>
  <h1>PDO wrapper file</h1>
  <pre><code>public function update($query, $values) 
  try{
          $sql = $this-&gt;db-&gt;prepare($query);
          $sql-&gt;execute($values);
          return true;
      } catch(PDOException $e) {
          $this-&gt;l-&gt;error($e); // &lt;- Error here
          return false;
      }
  }
  </code></pre>
  <p>$this-&gt;db is a correctly instantiated, fully connected PDO object;<br>These are the lines used to connect</p>
  <pre><code>$this-&gt;db = new PDO($connection, $this-&gt;db_user, $this-&gt;db_password, array(PDO::ATTR_PERSISTENT =&gt; true));
  $this-&gt;db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  </code></pre>
  <p>I have full access on the Mysql server</p>