Welcome to the LimeSurvey Community Forum

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 dir

  • wpfan2099
  • wpfan2099's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 6 months ago #189293 by wpfan2099
dear experts dear user


pretty new to limesurvey:


i run a root server with php version 5.6.39
i have enogh free space on the server




while trying to install limesurvey on my server i get back the following error
Code:
could not connect to the db: reason : SQLSTATE[HY000] [2002] No such file or directory
 



tried it several times - but without any success;: i googled the error

stackoverflow.com/questions/29695450/pdo...ch-file-or-directory

Quick test (run in shell):

Code:
 
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



and the following ideas:
Code:
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
 

see more here stackoverflow.com/questions/29695450/pdo...ch-file-or-directory



well all the trials faied so far


do you have any idea - whats going on here
The topic has been locked.
  • wpfan2099
  • wpfan2099's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 6 months ago - 4 years 6 months ago #189294 by wpfan2099
again me- here some more infos:

running a server and yes mysql is installed.

running PHP Version 5.6.39
mysqlnd 5.0.11-dev - 20120503
Code:
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

hmmm - i currently wonder why it does not work









here some more findings: : the folks / and user that face the same issue with the mentioned survey script as i do - they have posted some ideas and findings - food for thought:


cf: www.limesurvey.org/forum/installation-a-...-sqlstate-hy000-2002

klaus said: I run LimeSurvey on Linux for a few years now. After a reboot, probably an update, lime does not start anymore. I get the error
Code:
CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2002] No such file or directory


Following my research I looked for the connectionstring in the config.php and found:
Code:
'connectionString' => 'mysql:unix_socket=/usr/local/LimeSurvey/var/LimeSurvey_mysqld.sock;dbname=limesurvey;',


So I looked for the
Code:
/usr/local/LimeSurvey/var/LimeSurvey_mysqld.sock
file but it was not there. Further research results: change the connectionString to:
Code:
'connectionString' => 'mysql:host=127.0.0.1;unix_socket=/usr/local/LimeSurvey/var/LimeSurvey_mysqld.sock;dbname=limesurvey;',


...change the connectionString to:
Code:
'connectionString' => 'mysql:host=127.0.0.1;unix_socket=/usr/local/LimeSurvey/var/LimeSurvey_mysqld.sock;dbname=limesurvey;',


and this following idea:
Code:
Try
'connectionString' =>'mysql:host=localhost;port=3306;dbname=limesurvey;',

Are you sure DB still active mysql are on the same server?

I was able to fix it. The error showed that /tmp/mysql.sock was missing so I created a symbolic link with this command.
Code:
ln -s /usr/local/lib/mysql.sock /tmp/mysql.sock

see the tread for more infos: www.limesurvey.org/forum/installation-a-...-sqlstate-hy000-2002



conclusio: do you think that i have to do some corrections in the paths and the paths to socket!?



any idea how to check things !? Look forward to hear from you +


regards
Last edit: 4 years 6 months ago by wpfan2099.
The topic has been locked.
  • wpfan2099
  • wpfan2099's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 6 months ago #189328 by wpfan2099
since i get this annoying error in establishing db

i will try the Testconnection-Script to help out to verify the data


Code:
 
<?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);


hopefully i will get more insights
The topic has been locked.
  • wpfan2099
  • wpfan2099's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 6 months ago #189472 by wpfan2099
The following user(s) said Thank You: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose