Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eshmn's avatar
Level 1

PDOException - SQLSTATE[HY000] [2002] No such file or directory on Linux Mint

I have installed Laravel for the first time on my Linux Mint 18.0 and under Xampp. Following the instructions in https://laravel.com/docs/5.2/quickstart, when I ran the command php artisan migrate, I received the error: SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) Then, I searched for a solution and changed the .env file's db configuration to this:

DB_CONNECTION=mysql DB_HOST=localhost DB_DATABASE=laravelu DB_USERNAME=root DB_PASSWORD=''

Now I receive the error "PDOException - SQLSTATE[HY000] [2002] No such file or directory". I've tried some random solutions such as using a different environment (I tried php artisan migrate --env=production), but the problem still exists.

0 likes
5 replies
tomopongrac's avatar
Level 51

Try change DB_HOST from localhost to "127.0.0.1"

4 likes
eshmn's avatar
Level 1

@tomi I did. And the new error is: [PDOException] SQLSTATE[HY000] [1049] Unknown database 'laravelu' . I changed the DB_NAME to 'forge' and I still get the error [PDOException] SQLSTATE[HY000] [1049] Unknown database 'forge'

chadlinden's avatar

When laravel bootstraps (starts) it checks the config/database.php file to configure the connection, it also loads the .env file. If the database.php has a valid configuration, the app uses that, if the .env file has a valid configuration, it uses that.

So you have to decide to either put your DB configuration in database.php or .env Whatever you list as valid username, password, and host must match the database's username, password and host.

1 like

Please or to participate in this conversation.