Roots Discourse

Error establishing a database connection (no such file or directory)

Hello !

I can’t connect my BedRock installation to my local SQL server. All my tools are connected but bedrock doesn’t want.

My WP error :
Warning : mysqli_real_connect(): (HY000/2002): No such file or directory in /Users/victor/MyApp/lab/php/WP/web/wp/wp-includes/wp-db.php on line 1653

No such file or directory

My .env file :

Other tool with same conf but without problem :

When I request a list of my databases, with :
mysql -u <my_username> -p
show databases;

I have :
±-------------------+
| Database
±-------------------+
| information_schema
| mysql
| performance_schema
| sys
| wordpress
±-------------------+

Thanks for your help :pray:

Try using the direct IP and port your DB is configured on instead of the localhost:

DB_HOST='127.0.0.1:3306'

Additionally it looks as though you have setup a databse with SSL enabled. You’ll need to either setup a local database without SSL enabled. Or configure the WP Config with SSL Database configuration, for example:

define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT ); 
define('MYSQL_SSL_CA', '/path/to/your-ssl-cert.pem');
2 Likes

Thank you very much for your I tried your solutions, but the error of my PHP which was too old on my computer :sweat: So I updated it with brew (I’m on Mac OS).

brew install php

Everything works ! Thank you very much for your help and your responsiveness!

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.