I am just trying to create database using PHP but not creating.It giving me following error :
Access denied for user 'user'@'localhost'
I am using cPanel ,where i created a user with all privileges & this user assigned to a specific database
I am working on SaaS Application (i.e. multiple database & single codebase).
Please help me to solve this problem.
Code I am using
$dbhost = 'localhost:3306';
$dbuser = 'xyz';
$dbpass = 'xyz123';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
$sql = 'CREATE Database test_db';
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not create database: ' . mysql_error());
}
echo "Database test_db created successfully
";
mysql_close($conn);