File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -86,8 +86,29 @@ The connection string has the following syntax:
8686mysql://[user[:[password]]@]host[:port][/schema][?param1=value1¶m2=value2]
8787```
8888
89- Connection query params:
89+ #### Transport
9090
91- - encoding: The collation & charset (character set) to use during the connection.
91+ The driver supports tcp connection or unix sockets
92+
93+ - ` mysql://localhost ` will connect using tcp and the default MySQL port 3306.
94+ - ` mysql://localhost:8088 ` will connect using tcp using port 8088.
95+ - ` mysql:///path/to/other.sock ` will connect using unix socket ` /path/to/other.sock ` .
96+
97+ Any of the above can be used with ` user@ ` or ` user:password@ ` to pass credentials.
98+
99+ #### Default database
100+
101+ A ` database ` query string will specify the default database.
102+ Connection strings with a host can also use the first path component to specify the default database.
103+ Query string takes precedence because it's more explicit.
104+
105+ - ` mysql://localhost/mydb `
106+ - ` mysql://localhost:3306/mydb `
107+ - ` mysql://localhost:3306?database=mydb `
108+ - ` mysql:///path/to/other.sock?database=mydb `
109+
110+ #### Other query params
111+
112+ - ` encoding ` : The collation & charset (character set) to use during the connection.
92113 If empty or not defined, it will be set to ` utf8_general_ci ` .
93114 The list of available collations is defined in [ ` MySql::Collations::COLLATIONS_IDS_BY_NAME ` ] ( src/mysql/collations.cr )
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class MySql::Connection < DB::Connection
1616 transport = URI .new(" tcp" , host, port)
1717
1818 # for tcp socket we support the first component to be the database
19- # but the query string takes presedence because it's more explicit
19+ # but the query string takes precedence because it's more explicit
2020 if initial_catalog.nil? && (path = uri.path) && path.size > 1
2121 initial_catalog = path[1 ..- 1 ]
2222 end
You can’t perform that action at this time.
0 commit comments