Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Unix Domain Sockets for MySQL #449

Closed
pimeys opened this issue Jun 25, 2020 · 3 comments
Closed

Support Unix Domain Sockets for MySQL #449

pimeys opened this issue Jun 25, 2020 · 3 comments

Comments

@pimeys
Copy link
Contributor

pimeys commented Jun 25, 2020

We need this in many cases, especially when working with Google's databases and developer tools, sockets can be quite common.

The Socket implementation in SQLx should not be PostgreSQL-specific as it is right now. Also the socket should be specified by the user, it can be different depending on the environment. For example GCP creates a socket bridge to the disk, which is not the default location found from your normal PostgreSQL installation.

The connection string in MySQL when using a socket should be:

mysql://root@localhost/dbname?socket=(/tmp/mysql.sock)

Then again PostgreSQL has following format for UDS:

postgresql://root@/dbname?host=/tmp/.s.PGSQL.5432

So this issue would require changes for a few things:

  • Making Socket to be generic for PostgreSQL and MySQL
  • Allowing one to define the location of the socket either through options or connection string
@pimeys
Copy link
Contributor Author

pimeys commented Jun 25, 2020

Also, I'd like to implement this :)

@pimeys
Copy link
Contributor Author

pimeys commented Jun 25, 2020

After a discussion on Discord, the right way to define sockets would be:

PostgreSQL:

postgresql://root@/dbname?host=/tmp
// or
postgresql://root@%2ftmp/dbname

The socket name in the directory is defined from the port, typically being .s.PGSQL.5432 with the default port.

MySQL:

mysql:///database_name?socket=/tmp/mysql.sock

Here we define the full path to the socket file.

@mehcode
Copy link
Member

mehcode commented Jun 28, 2020

Support was merged in with #450. Thanks @pimeys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants