php - PDO access denied for user 'username'@'%' -
i need connect remote mysql server using php page;
the connection works charm, moment try create database, doesn't exist yet, error:
exception 'pdoexception' message 'sqlstate[42000]: syntax error or access violation: 1044 access denied user '[myusername]'@'%' database '[mydbname]'' in [myurl]/php/db_manager.php:76
as can see, have access denied "%".
now: "%"?
furthermore:
main file
private function createdb() { if($this->cm->update("create database if not exists " . $this->dbname . " default character set utf8 collate utf8_general_ci;", array())) { // error here $this->cm->update("use " . $this->dbname . ";", array()); return true; } return false; }
$this->cm instance of correctly initialized pdo wrapper
pdo wrapper file
public function update($query, $values) try{ $sql = $this->db->prepare($query); $sql->execute($values); return true; } catch(pdoexception $e) { $this->l->error($e); // <- error here return false; } }
$this->db correctly instantiated, connected pdo object;
these lines used connect
$this->db = new pdo($connection, $this->db_user, $this->db_password, array(pdo::attr_persistent => true)); $this->db->setattribute(pdo::attr_errmode, pdo::errmode_exception);
i have full access on mysql server
access denied user '[myusername]'@'%' to database '[mydbname]'
mysql permissions granular: not users have full access databases on server.
you need sign in administrator , grant appropriate permissions. instance, grant full access:
grant on mydbname.* 'myusername'@'%' grant option; flush privileges;
... or can more selective liking:
grant select, alter, create, delete, drop, index, insert, references, trigger, update on mydbname.* 'myusername'@'%'; flush privileges;
please check privileges supported mysql full list.
%
wildcard explained in detail @ account names , passwords means "connection host".
Comments
Post a Comment