- Posts: 70
- Thank you received: 3
Ask the community, share ideas, and connect with other LimeSurvey users!
could not connect to the db: reason : SQLSTATE[HY000] [2002] No such file or directory
php -r "new PDO('mysql:hostname=localhost;dbname=test', 'username', 'password');" SQLSTATE[HY000] [2002] No such file or directory means php cannot find the mysql.default_socket file. Fix it by modifying php.ini file. On Mac it is mysql.default_socket = /tmp/mysql.sock (See PHP - MySQL connection not working: 2002 No such file or directory) SQLSTATE[HY000] [1044] Access denied for user 'username'@'localhost' CONGRATULATION! You have the correct mysql.default_socket setting now. Fix your dbname/username/password. Also see Error on creating connection to PDO in PHP
You need to change host from localhost to 127.0.0.1 Laravel 4: In your app/config/database.php try changing host from localhost to 127.0.0.1 Laravel 5: In the .env file, change DB_HOST from localhost to 127.0.0.1 Source: PDOException SQLSTATE[HY000] [2002] No such file or directory shareeditflag
mysqli.default_host localhost localhost mysqli.default_port 3306 3306 mysqli.default_pw no value no value mysqli.default_socket /var/run/mysql/mysql.sock /var/run/mysql/mysql.sock
CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2002] No such file or directory
'connectionString' => 'mysql:unix_socket=/usr/local/LimeSurvey/var/LimeSurvey_mysqld.sock;dbname=limesurvey;',
/usr/local/LimeSurvey/var/LimeSurvey_mysqld.sock
'connectionString' => 'mysql:host=127.0.0.1;unix_socket=/usr/local/LimeSurvey/var/LimeSurvey_mysqld.sock;dbname=limesurvey;',
'connectionString' => 'mysql:host=127.0.0.1;unix_socket=/usr/local/LimeSurvey/var/LimeSurvey_mysqld.sock;dbname=limesurvey;',
Try 'connectionString' =>'mysql:host=localhost;port=3306;dbname=limesurvey;',
<?php if(function_exists('mysqli_connect')){ if(!($link = mysqli_connect('localhost','username','password','my_db'))){ die('could not connect: ' . mysqli_error($link)); } } else { die("don't have mysqli"); } echo 'connect successfully'; mysqli_close($link);