M
M
Maks Burkov2017-10-10 02:07:22
PHP
Maks Burkov, 2017-10-10 02:07:22

PDOException SQLSTATE[HY000] [2002] No such file or directory, How to fix and why it happens?

Can someone explain what's going on here? Where what to configure and what where?
I am doing the following checks..
Checking php.ini -> Pdo_mysql and mysql section:
pdo_mysql.default_socket=/tmp/mysql.sock
mysql.default_socket=/tmp/mysql.sock
Checking php -i | grep pdo on mac :
pdo_mysql.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
Check etc/my.cnf :
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
Check show variables like '%socket%' = /tmp/mysql.sock
Code:

$db = new PDO("mysql:host=localhost;dbname=users;port=3306",'root','[email protected]@');
 print_r($db);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question