You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -38,15 +39,15 @@ A MySQL-Driver for Go's [database/sql](https://golang.org/pkg/database/sql/) pac
38
39
* Optional placeholder interpolation
39
40
40
41
## Requirements
41
-
* Go 1.2 or higher
42
+
* Go 1.5 or higher
42
43
* MySQL (4.1+), MariaDB, Percona Server, Google CloudSQL or Sphinx (2.2.3+)
43
44
44
45
---------------------------------------
45
46
46
47
## Installation
47
48
Simple install the package to your [$GOPATH](https://github.com/golang/go/wiki/GOPATH"GOPATH") with the [go tool](https://golang.org/cmd/go/"go command") from shell:
48
49
```bash
49
-
$ go get github.com/go-sql-driver/mysql
50
+
$ go get -u github.com/go-sql-driver/mysql
50
51
```
51
52
Make sure [Git is installed](https://git-scm.com/downloads) on your machine and in your system's `PATH`.
52
53
@@ -100,7 +101,8 @@ See [net.Dial](https://golang.org/pkg/net/#Dial) for more information which netw
100
101
In general you should use an Unix domain socket if available and TCP otherwise for best performance.
101
102
102
103
#### Address
103
-
For TCP and UDP networks, addresses have the form `host:port`.
104
+
For TCP and UDP networks, addresses have the form `host[:port]`.
105
+
If `port` is omitted, the default port will be used.
104
106
If `host` is a literal IPv6 address, it must be enclosed in square brackets.
105
107
The functions [net.JoinHostPort](https://golang.org/pkg/net/#JoinHostPort) and [net.SplitHostPort](https://golang.org/pkg/net/#SplitHostPort) manipulate addresses in this form.
106
108
@@ -137,9 +139,9 @@ Default: false
137
139
```
138
140
Type: bool
139
141
Valid Values: true, false
140
-
Default: false
142
+
Default: true
141
143
```
142
-
`allowNativePasswords=true` allows the usage of the mysql native password method.
144
+
`allowNativePasswords=false` disallows the usage of MySQL native password method.
143
145
144
146
##### `allowOldPasswords`
145
147
@@ -267,6 +269,31 @@ Default: 0
267
269
268
270
I/O read timeout. The value must be a decimal number with a unit suffix (*"ms"*, *"s"*, *"m"*, *"h"*), such as *"30s"*, *"0.5m"* or *"1m30s"*.
269
271
272
+
##### `rejectReadOnly`
273
+
274
+
```
275
+
Type: bool
276
+
Valid Values: true, false
277
+
Default: false
278
+
```
279
+
280
+
281
+
`rejectreadOnly=true` causes the driver to reject read-only connections. This
282
+
is for a possible race condition during an automatic failover, where the mysql
283
+
client gets connected to a read-only replica after the failover.
284
+
285
+
Note that this should be a fairly rare case, as an automatic failover normally
286
+
happens when the primary is down, and the race condition shouldn't happen
287
+
unless it comes back up online as soon as the failover is kicked off. On the
288
+
other hand, when this happens, a MySQL application can get stuck on a
289
+
read-only connection until restarted. It is however fairly easy to reproduce,
290
+
for example, using a manual failover on AWS Aurora's MySQL-compatible cluster.
291
+
292
+
If you are not relying on read-only transactions to reject writes that aren't
293
+
supposed to happen, setting this on some MySQL providers (such as AWS Aurora)
294
+
is safer for failovers.
295
+
296
+
270
297
##### `strict`
271
298
272
299
```
@@ -318,9 +345,9 @@ Any other parameters are interpreted as system variables:
* The values for string variables must be quoted with '
348
+
* The values for string variables must be quoted with `'`.
322
349
* The values must also be [url.QueryEscape](http://golang.org/pkg/net/url/#QueryEscape)'ed!
323
-
(which implies values of string variables must be wrapped with `%27`)
350
+
(which implies values of string variables must be wrapped with `%27`).
324
351
325
352
Examples:
326
353
*`autocommit=1`: `SET autocommit=1`
@@ -400,7 +427,7 @@ See the [godoc of Go-MySQL-Driver](https://godoc.org/github.com/go-sql-driver/my
400
427
401
428
402
429
### `time.Time` support
403
-
The default internal output type of MySQL `DATE` and `DATETIME` values is `[]byte` which allows you to scan the value into a `[]byte`, `string` or `sql.RawBytes` variable in your programm.
430
+
The default internal output type of MySQL `DATE` and `DATETIME` values is `[]byte` which allows you to scan the value into a `[]byte`, `string` or `sql.RawBytes` variable in your program.
404
431
405
432
However, many want to scan MySQL `DATE` and `DATETIME` values into `time.Time` variables, which is the logical opposite in Go to `DATE` and `DATETIME` in MySQL. You can do that by changing the internal output type from `[]byte` to `time.Time` with the DSN parameter `parseTime=true`. You can set the default [`time.Time` location](https://golang.org/pkg/time/#Location) with the `loc` DSN parameter.
406
433
@@ -418,6 +445,9 @@ Version 1.0 of the driver recommended adding `&charset=utf8` (alias for `SET NAM
418
445
419
446
See http://dev.mysql.com/doc/refman/5.7/en/charset-unicode.html for more details on MySQL's Unicode support.
420
447
448
+
## `context.Context` Support
449
+
Go 1.8 added `database/sql` support for `context.Context`. This driver supports query timeouts and cancellation via contexts.
450
+
See [context support in the database/sql package](https://golang.org/doc/go1.8#database_sql) for more details.
421
451
422
452
## Testing / Development
423
453
To run the driver tests you may need to adjust the configuration. See the [Testing Wiki-Page](https://github.com/go-sql-driver/mysql/wiki/Testing"Testing") for details.
@@ -437,13 +467,13 @@ Mozilla summarizes the license scope as follows:
437
467
438
468
439
469
That means:
440
-
* You can **use** the **unchanged** source code both in private and commercially
441
-
* When distributing, you **must publish** the source code of any **changed files** licensed under the MPL 2.0 under a) the MPL 2.0 itself or b) a compatible license (e.g. GPL 3.0 or Apache License 2.0)
442
-
* You **needn't publish** the source code of your library as long as the files licensed under the MPL 2.0 are **unchanged**
470
+
* You can **use** the **unchanged** source code both in private and commercially.
471
+
* When distributing, you **must publish** the source code of any **changed files** licensed under the MPL 2.0 under a) the MPL 2.0 itself or b) a compatible license (e.g. GPL 3.0 or Apache License 2.0).
472
+
* You **needn't publish** the source code of your library as long as the files licensed under the MPL 2.0 are **unchanged**.
443
473
444
474
Please read the [MPL 2.0 FAQ](https://www.mozilla.org/en-US/MPL/2.0/FAQ/) if you have further questions regarding the license.
445
475
446
-
You can read the full terms here: [LICENSE](https://raw.github.com/go-sql-driver/mysql/master/LICENSE)
476
+
You can read the full terms here: [LICENSE](https://raw.github.com/go-sql-driver/mysql/master/LICENSE).
447
477
448
478

0 commit comments