'How to connect to unix socket path in a connection string (slonik)?

Good Day!

I got an error when I try to connect to db Google Cloud by dint of slonik:

const pool = createPool(
`socket:userName:password@/cloudsql/teest-123986:europe-west3:test?db=dbName`
)

I got:

error: throw new Error('SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string')

When I checked I saw that password = null (parser of string gave incorrect value).

I used this guide for connection string.

Why I got this error?



Solution 1:[1]

After many tries this connection string worked:

socket://${process.env.SQL_USER}:${process.env.SQL_PASSWORD}@${process.env.IP_DB_PRIVATE}?db=${process.env.DB}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andres