XAMPP, MAMP, MySQL, PDO - A deadly combination?
Posted
by Rich
on Stack Overflow
See other posts from Stack Overflow
or by Rich
Published on 2010-06-11T11:03:38Z
Indexed on
2010/06/11
11:23 UTC
Read the original article
Hit count: 193
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.
© Stack Overflow or respective owner