Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 5 - SQLSTATE[HY000] [2002] No such file or directory

Tags:

php

mysql

symfony

I'm running a Symfony 5 project on my Ubuntu machine, and when I try to import my database I had created to my project I get the following error:

enter image description here

The thing is I'm going through a tutorial a second time to create my own project, and the first project works just fine. The DATABASE_URL in the .env files on these two project are the same (double and triple checked),

here's the .env enter image description here

I've tried changing localhost to 127.0.0.1 but the error changes to 'Connection refused', and I also tried adding the real path to the mysql.sock to the php.ini. These are the solutions I've found that apply to my problem, nothing worked so far.

Any ideas would be greatly appreciated!!

like image 818
Marcel Puy Avatar asked Nov 30 '25 03:11

Marcel Puy


1 Answers

Have you defined a path to your socket in the config/packages/doctrine.yaml? See the marked answer here

I think that setting localhost to 127.0.0.1 fixes your initial problem, but then you are getting connection refused as the server isn't accepting your credentials.

If you aren't using a socket, then you need to pass a password in to your DATABASE_URL:

DATABASE_URL=mysql://root:[email protected]:3306/beers?serverVersion=5.7
like image 63
Bertyterty Avatar answered Dec 02 '25 17:12

Bertyterty



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!