Starting with Zend Tutorial - Zend_DB_Adapter throws Exception: "SQLSTATE[HY000] [2002] No such file or directory" -
i start learning zend framework book "zend framework in action" in german.
right there start interesting php unit test throws error: "zend_db_adapter_exception: sqlstate[hy000] [2002] no such file or directory"
i cant find hints @ google. did in book. can give me hint search fault?
is usual beginner mistake?
i have problem connecting php mysql...
something php trying find socket file, , not finding it, maybe ?
(i've had problem couple of times -- not sure error got one, though)
if running linux-based system, there should my.cnf
file somewhere, used configure mysql -- on ubuntu, it's in /etc/mysql/
.
in file, there might :
socket = /var/run/mysqld/mysqld.sock
php need use same file -- and, depending on distribution, default file might not same 1 mysql uses.
in case, adding these lines php.ini
file might :
mysql.default_socket = /var/run/mysqld/mysqld.sock mysqli.default_socket = /var/run/mysqld/mysqld.sock pdo_mysql.default_socket = /var/run/mysqld/mysqld.sock
(you'll need restart apache modification php.ini
taken account)
the last 1 should enough pdo, used zend framework -- 2 previous ones not harm, , can useful other applications.
if doesn't : can connect database using pdo, in script, that's totally independant of zend framework ?
i.e. work (quoting) :
$dsn = 'mysql:dbname=testdb;host=127.0.0.1'; $user = 'dbuser'; $password = 'dbpass'; try { $dbh = new pdo($dsn, $user, $password); } catch (pdoexception $e) { echo 'connection failed: ' . $e->getmessage(); }
if no, problem definitly not zf, , configuration / installation problem of php.
if yes... well, means have problem zf, , you'll need give more informations setup (like dsn, instance ? )
Comments
Post a Comment