I'm using hostgator
for hosting my website and I have added my IP
address as remote access host. And then I connected with mySql workbench and tested the connection and I get the message that all parameters are correct. On hostgator, I added myself as a the admin user granting myself all privileges. Now I want to manipulate the database via a PHP script using PDO but this is the error I'm getting in my browser when I try to run the PHP file:
Connection failed: SQLSTATE[28000] [1045] Access denied for user 'user'@'host' (using password: YES)
On mySQL workbench Users and Privileges tab, I get this:
"The account you are currently using does not have sufficient privileges to make changes to MySQL users and privileges.
"
I'm not sure whats going wrong here and I'm quiet new to this. Can somebody please help?
edit:
php code below:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
//this block tries to connect to the database
//if there's an error connecting, the code under catch will
//and the program will end
$host="host";
$port="3306";
$user="xxx";
$password="xxx";
$dbname="database";
try {
$conn = new PDO("mysql:host=$host;dbname=$dbname;", $user, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
//$con->close();
?>