balderdashy / balderdashy/sails
Problem connecting to MySQL via unix socket
- Dominant language
- JavaScript
- Stars
- 22.8k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
**Node version**: v10.15.3
**Sails version** _(sails)_: 1.2.3
**ORM hook version** _(sails-hook-orm)_: 2.1.1
**Sockets hook version** _(sails-hook-sockets)_: 2.0.0
**Organics hook version** _(sails-hook-organics)_: 0.16.0
**Grunt hook version** _(sails-hook-grunt)_: 4.0.1
**Uploads hook version** _(sails-hook-uploads)_: n/a
**DB adapter & version** _(e.g. sails-mysql@5.55.5)_: sails-mysql@1.0.1
**Skipper adapter & version** _(e.g. skipper-s3@5.55.5)_: n/a
Hey team,
I'm trying to connected to my production database using a unix socket path, I am trying to do this because it is the most secure way that GCP allows me to connect.
I looked into #6547, but couldn't get it to work, that issue was a few years old and it looks like they were messing with adapters.js, which does not exist in my installation of sails.
I've tried putting the datastore config both directly in config/env.production.js, as well as in config/datastores.js, with no luck.
Here is my configuration:
```
adapter: 'sails-mysql',
user: 'root',
password: process.env.MYSQL_ROOT_PASSWORD,
database: process.env.MYSQL_DATABASE,
socketPath: process.env.DB_SOCKET_CONNECTION_STRING,
```
The errors I get vary depending on what I change, but it's usually either ERRCONNECT-REFUSED when it ignores my configuration and tries to use the default development one. Or it's a sails error saying my datastore is invalid because I'm not passing a connectionString:
```
error: Failed to lift app: Error: There was an error creating a new manager for the connection with a url of: undefined
2019-10-22 21:32:36.677 CDT
2019-10-22 21:32:36.677 CDTUsageError: Could not run createManager() because of a problem:
2019-10-22 21:32:36.677 CDT------------------------------------------------------
2019-10-22 21:32:36.677 CDT• "connectionString" is required, but it was not defined.
2019-10-22 21:32:36.677 CDT------------------------------------------------------
```
Thanks for any help :)
Contributor guide
Research direction
Start by reviewing the datastore configuration in config/env.production.js and config/datastores.js, then reproduce the reported production setup using the shown sails-mysql configuration. Done means the application uses the configured Unix socket and connects to the intended MySQL database without falling back to development settings or requiring an undefined connectionString.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mysql, node.js
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100