php - Error when using PDO -
so installed pdo drivers, , have issue. when try use
<?php $username = "root"; $password = "allen123"; $conn = new pdo('mysql:host=localhost;dbname=test', $username, $password); ?> just connect db, following error
fatal error: uncaught exception 'pdoexception' message 'sqlstate[hy000] [2002] no such file or directory' in /users/idrisk/colourity/site/index.php:4 stack trace: #0 /users/idrisk/colourity/site/index.php(4): pdo->__construct('mysql:host=loca...', 'root', 'allen123') #1 {main} thrown in /users/idrisk/colourity/site/index.php on line 4
i've looked @ other posts on issue, seem different. ideas?
edit
so installed drivers via macports , once installed
to use mysqlnd local mysql server, edit /opt/local/etc/php55/php.ini , set mysql.default_socket, mysqli.default_socket , pdo_mysql.default_socket path mysql server's socket file.
for mysql51, use /opt/local/var/run/mysql51/mysqld.sock mysql55, use /opt/local/var/run/mysql55/mysqld.sock mysql56, use /opt/local/var/run/mysql56/mysqld.sock mariadb, use /opt/local/var/run/mariadb/mysqld.sock percona, use /opt/local/var/run/percona/mysqld.sock` the other answers use else.
Comments
Post a Comment