I'm trying to connect to a offloaded SQL server offered here. It says that I should connect using the internal IP

I installed nginx and PHP (php5-fpm, php5-mysql) on my VPS. phpinfo() works, too. However, when I try to connect to the server, I get the following error. I tried connecting to the server using its external IP, but I still get the same error.

SQLSTATE[28000] [1045] Access denied for user 'myuser'@'AAA.BBB.CCC.DDD' (using password: YES)

AAA.BBB.CCC.DDD is the IP of my VPS, not the server's. This is strange because I did not specify this IP when connecting the server.

Here is the PHP code I use.

try {
    $dsn = 'mysql:host=;dbname=myuser_mydatabase;charset=utf8';

    $db = new PDO($dsn,'myuser','mypassword');

    $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
} catch (PDOException $e) {
    echo 'PDO error: ' . $e->getMessage();

What am I doing wrong here?

EDIT: FYI, user myuseris the default user I was given when I signed up for the offloaded SQL. I checked that it has given all grants to all databases. I also created a new database and user through cPanel, and granted appropriate access. I still cannot get this to work. I get the same error.

EDIT2: I added my vps's IP address to the list of allowed hosts from cPanel, but this did not solve the problem, either.

EDIT3: Please see my answer.


Well, this is embrassing. I just did not wait long enough after adding my VPS's IP to the list of allowed hosts. I'll leave this up here just in case anyone find this information useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.