I created a new database, created a user and granted all access to this user. But when I am trying to set password for localhost
. I'm getting error -
Can't find any matching row in the user table
Here's what I am doing in php code -
mysql_query("CREATE DATABASE ".$ThisDBName."",$con1) or die(mysql_error());
mysql_query("GRANT ALL ON ".$ThisDBName.".* to ".$ThisDBUserName." identified by '".$ThisDBPassword."'",$con1) or die(mysql_error());
I searched for this error and tried using FLUSH PRIVILEGES
before SET PASSWORD
mysql_query("FLUSH PRIVILEGES",$con1) or die(mysql_error());
mysql_query("SET PASSWORD FOR " . $ThisDBUserName ." @'localhost' = PASSWORD(".$ThisDBPassword.")",$con1) or die(mysql_error());
But still I'm getting the same error and can not connect using mysql_connect()
.
I also tried answers of this similar question but that too doesn't work for me.