views:

152

answers:

1

Hey folks,

Previously I've worked on a Symfony project (MySQL PDO based) with XAMPP, with no problems.

Since then, I've moved to MAMP - I prefer this - but have hit a snag with my database connection.

I've created a test.php like this:

<?php
try {
    $dbh = new PDO('mysql:host=localhost;dbname=xxx;port=8889', 'xxx', 'xxx');
    foreach($dbh->query('SELECT * from FOO') as $row) {
        print_r($row);
    }
    $dbh = null;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
}
?>

Obviously the *xxx*s are real db connection details.

Which when served by MAMP seems to work fine.

From terminal however I keep getting the following error when running the file:

Error!: SQLSTATE[28000] [1045] Access denied for user 'xxx'@'localhost' (using password: YES)

Not sure if the terminal is aiming at a different MySQL socket or something along those lines; but I've tried pointing it to the MAMP socket with a local php.ini file.

Any help would be greatly appreciated.

A: 

Figured out that the PHP command is pointing to the XAMPP folder, when I need it pointing to the MAMP folder! Sorry!

Rich