PDOException SQLSTATE[HY000] [2002] No such file or directory

Problem

After setting up my Laravel app and trying to connect via SSH to run some commands (such asphp artisan migrate[cci] or [cci lang="php"php artisan db:seed) I get an error message:

[PDOException]
SQLSTATE[HY000] [2002] No such file or directory

I can see that my tables are there, so it might have worked before – but this doesn’t explain why it isn’t working for me now.

Solution

It’s not a big deal. This error message indicates that a MySQL connection via socket is tried (but it seems that it isn’t supported).

When it comes to running Laravel commands (eg. artisan), you probably want to use a different environment. Eg: php artisan migrate --env=production (or whatever environment). See here.

In addition try this for Laravel 5: Change “DB_HOST” in the .env file from “localhost” to “127.0.0.1”



from Linux Hint https://ift.tt/3ak4mvA

Post a Comment

0 Comments