invoiceninja / dockerfiles

Docker files for Invoice Ninja
https://hub.docker.com/r/invoiceninja/invoiceninja
GNU General Public License v2.0
392 stars 255 forks source link

SQLSTATE[HY000] [2002] No such file or directory #368

Closed atajsic closed 3 years ago

atajsic commented 3 years ago

Setup information docker-compose

docker-compose fails to start container when environment variables in env are set to DB_HOST DB_DATABASE DB_USERNAME DB_PASSWORD

etc.

Changing the variables in the env file to DB_HOST1 DB_DATABASE1 DB_USERNAME1 DB_PASSWORD1

etc. as outlined here seems to fix the issue and the container will load properly.

Screenshots/logs invoiceninja5_1 | 2021-07-01T14:22:07Z [INFO] [Entrypoint]: Initialising Invoice Ninja... invoiceninja5_1 | Configuration cache cleared! invoiceninja5_1 | Configuration cached successfully! invoiceninja5_1 | Configuration cache cleared! invoiceninja5_1 | Configuration cached successfully! invoiceninja5_1 | Route cache cleared! invoiceninja5_1 | Routes cached successfully! invoiceninja5_1 | Files cached successfully! invoiceninja5_1 | invoiceninja5_1 | In Connection.php line 692: invoiceninja5_1 | invoiceninja5_1 | SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from inform invoiceninja5_1 | ation_schema.tables where table_schema = ninja and table_name = accounts an invoiceninja5_1 | d table_type = 'BASE TABLE') invoiceninja5_1 | invoiceninja5_1 | invoiceninja5_1 | In Exception.php line 18: invoiceninja5_1 | invoiceninja5_1 | SQLSTATE[HY000] [2002] No such file or directory invoiceninja5_1 | invoiceninja5_1 | invoiceninja5_1 | In PDOConnection.php line 39: invoiceninja5_1 | invoiceninja5_1 | SQLSTATE[HY000] [2002] No such file or directory invoiceninja5_1 | invoiceninja5_1 | invoiceninja5_1 | 2021-07-01T14:22:09Z [ERROR] [Entrypoint]: Error connecting to DB

lwj5 commented 3 years ago

Yes I realised. You are running 5.2.7 correct?

LivingWithHippos commented 3 years ago

THANKS I thought I had to recreate everything. I added the "1" version of the variables to the env file so now it has both and I don't have to risk a panic attack everytime this happen. I think it happened between 5.2.7 and 5.2.6 yes.

atajsic commented 3 years ago

Yes I realised. You are running 5.2.7 correct?

Yes that's right, I'm using 5.2.7, latest at the time of this comment

tilllt commented 3 years ago

Just to chime in ... it took me a couple of hours to figure this out myself, unfortunately i hadnt seen this solution before.

It is sufficient to change DB_HOST1=db to get the docker container (in my use-case docker-compose base) solution running.

hillelcoren commented 3 years ago

Thanks for sharing this!

@turbo124 @beganovich @lwj5 any thoughts on what the root problem here is, this specific problem/solution has been reported by a few people now.

beganovich commented 3 years ago

Change to suffix everything with 1 looks good to me, ping @turbo124

hillelcoren commented 3 years ago

Or make it work without the 1, most users won't be using using the multi-db setup

lwj5 commented 3 years ago

I think I found the issue, will push a fix in a bit

hillelcoren commented 3 years ago

@lwj5 amazing, thank you!

lwj5 commented 3 years ago

It looks like the fix has already been included in 5.2.8. So Just update to 5.2.8 and it should be all good.

IrealiTY commented 3 years ago

I'd like to re-open this issue, I did a fresh git pull earlier and the error mentioned above pops up.

app_1     | In Connection.php line 678:
app_1     |
app_1     |   SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from inform
app_1     |   ation_schema.tables where table_schema = ninja and table_name = accounts an
app_1     |   d table_type = 'BASE TABLE')
app_1     |
app_1     |
app_1     | In Exception.php line 18:
app_1     |
app_1     |   SQLSTATE[HY000] [2002] No such file or directory
app_1     |
app_1     |
app_1     | In PDOConnection.php line 38:
app_1     |
app_1     |   SQLSTATE[HY000] [2002] No such file or directory
app_1     |
app_1     |
app_1     | [18-Jul-2021 13:28:26] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
app_1     | [18-Jul-2021 13:28:26] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
app_1     | [18-Jul-2021 13:28:26] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
app_1     | [18-Jul-2021 13:28:26] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
app_1     | [18-Jul-2021 13:28:26] NOTICE: fpm is running, pid 1
app_1     | [18-Jul-2021 13:28:26] NOTICE: ready to handle connections

changing DB_HOST=db to DB_HOST1=db inside the env file seems to trigger some kind of change

but results in access errors

app_1     | In Connection.php line 678:
app_1     |
app_1     |   SQLSTATE[HY000] [1045] Access denied for user ''@'172.23.0.3' (using passwo
app_1     |   rd: NO) (SQL: select * from information_schema.tables where table_schema =
app_1     |   ninja and table_name = accounts and table_type = 'BASE TABLE')
app_1     |
app_1     |
app_1     | In Exception.php line 18:
app_1     |
app_1     |   SQLSTATE[HY000] [1045] Access denied for user ''@'172.23.0.3' (using passwo
app_1     |   rd: NO)
app_1     |
app_1     |
app_1     | In PDOConnection.php line 38:
app_1     |
app_1     |   SQLSTATE[HY000] [1045] Access denied for user ''@'172.23.0.3' (using passwo
app_1     |   rd: NO)
app_1     |
app_1     |
app_1     | [18-Jul-2021 13:26:47] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
app_1     | [18-Jul-2021 13:26:47] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
app_1     | [18-Jul-2021 13:26:47] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
app_1     | [18-Jul-2021 13:26:47] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
app_1     | [18-Jul-2021 13:26:47] NOTICE: fpm is running, pid 1
app_1     | [18-Jul-2021 13:26:47] NOTICE: ready to handle connections
LivingWithHippos commented 3 years ago

Since it's saying "using password NO" maybe you need to also add the 1 to DB_PASSWORD. Or, as I was suggesting just leave both the variables with the 1 and without it so this does not happen again. For what it's worth I just updated my container and I did not have your problem.

IrealiTY commented 3 years ago

Adding a 1 to all variables seems to have done the trick. Could've sworn I tried that earlier but must've forgotten to save.

I also had to create the docker/mysql/data folder myself not sure if that some weird synology permission thing.