Repository navigation
Connect over a Unix socket - #264
Merged
Merged
Conversation
protocol=:socket, and host localhost with a unix_socket path (keyword, option file, or MYSQL_UNIX_PORT with read_env), connect through Reseau.Unix. TLS stays TCP-only; a local socket counts as a secure transport for authentication, as in Connector/C. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
protocol=:socket needs host localhost, as in libmysqlclient. On Windows a socket path leaves localhost on TCP. A Unix socket counts as secure for caching_sha2_password only: the server accepts a cleartext sha256_password only over TLS. The protocol kind is narrowed to a Symbol before socket_path, which keeps ConnectOptions trim-safe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quinnj-bot
Bot
force-pushed
the
claude/mysql-unix-socket
branch
from
November 16, 2026 20:34
b5a7735 to
ba204a7
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quinnj
approved these changes
Nov 16, 2026
quinnj
left a comment
Member
There was a problem hiding this comment.
Approving. MySQL.jl can now connect through a local server's Unix socket: use unix_socket with host localhost, or protocol=:socket. TLS stays TCP-only.
A socket counts as secure for caching_sha2_password only, matching the server. sha256_password still uses RSA over a socket.
An independent review found two bugs at b5a7735: a trim failure, and sha256_password logins rejected over a socket. It also flagged two selection gaps: non-localhost hosts with protocol=:socket, and the Windows default. The fix round addressed all four, and a re-review passed at ba204a7.
Verification:
- The live socket logins pass on Linux CI against mysql:8.4 and mariadb:11.4.
- The full suite passed locally on 1.12, 1916/1916, with a clean trim build.
- CI is green at 08cb272.
[review generated via AI]
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
MySQL.jl 2.x connects only over TCP. A local server that listens only on a Unix socket can't be reached. Today
unix_socketandsocket=in an option file are accepted but ignored, andprotocol=:socketraises "not supported yet". Reseau has had a Unix socket client since 1.6.0 (Reseau.Unix.connect).Change
Transport selection follows Connector/C, with one difference noted below.
protocol=:socketwith hostlocalhostunix_socket, or/tmp/mysql.sockprotocol=:socketwith any other hostArgumentError(libmysqlclient: error 2047)localhostwith a socket path (unix_socket,socketin an option file, orMYSQL_UNIX_PORTwithread_env=true)localhostwithout a path/tmp/mysql.sock)protocol=:tcpssl_mode=:preferredconnects without TLS, as Connector/C does for local sockets. A setting that requires TLS raises anArgumentErrorbefore connecting::required, the verify modes, orssl_ca/ssl_capath. So doesbind.caching_sha2_password, a local socket counts as secure, as it does in the server and in libmysqlclient. So full authentication sends the password directly instead of using RSA. The newAuthPolicy.local_socketcarries this.sha256_passwordstill uses RSA over a socket, because the server accepts its cleartext password only over TLS.mysql_clear_passwordstill requires:verify_identityorinsecure_cleartext_auth=true.Reseau.Unix.Connjoins theTransportunion. To keep the union at four concrete types, which keeps transport calls statically dispatched, the test-onlyFaultTransportis no longer parametric. ItsinnerisUnion{IOBuffer, Reseau.TCP.Conn}.1.7(from Support passphrase and ssl_ca with ssl_capath #263); the Unix client needs 1.6.Behavior change. An option file with
socket=and hostlocalhost, such as a stockmy.cnf, used to connect over TCP. It now uses that socket, as Connector/C does. Passprotocol=:tcpto keep TCP.Verification
test/protocol/unix_socket_tests.jlserves the fake peer on a real Unix socket (Sockets.listen(path)). It connects with hostlocalhostandunix_socket, with and withoutprotocol=:socket. The peer asks for full authentication and requires the cleartext password, and the client's trace records:full_auth_cleartext. A missing socket path raisesSystemError. A policy test checks thatsha256_passwordstill requests the RSA key over a socket.test/protocol/native_tests.jlcovers selection: the keyword, the option file,MYSQL_UNIX_PORT,protocol, a non-localhosthost, the TLS andbinderrors, and Windows.caching_sha2_passworduser and log in over the socket, with:full_auth_cleartextchecked on MySQL 8.4. Docker Desktop can't pass a socket through to macOS, so this check runs only on Linux CI.SystemError, and the deferred-transport row usesprotocol=:pipe.🤖 Generated with Claude Code