I tried to set up a new local drupal9 site using Lando, but it is unable to connect to the database and I am getting the following error.
Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] No such file or directory.
Checking the Lando logs shows the following.
PDOException: SQLSTATE[HY000] [2002] No such file or directory in /app/web/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php on line 79
I checked and it seems to be resolved by putting the location of mysql.sock file in settings.php as shown below.
I've got `PDOException: SQLSTATE[HY000] [2002] No such file or directory` when using drush
Then I checked mysql status and found the following.
UNIX socket: /opt/bitnami/mysql/tmp/mysql.sock
The final result was as follows. But even if I change the host to 127.0.01, etc., the error message does not change.
$databases['default']['default'] = [
'database' => 'drupal9',
'username' => 'drupal9',
'password' => 'drupal9',
'host' => 'localhost',
'port' => '3306',
'driver' => 'mysql',
'prefix' => '',
'unix_socket' => '/opt/bitnami/mysql/tmp/mysql.sock',
];
If I've made any mistakes so far, please let me know.
Thank you.