Skip to content

Commit f0e16c6

Browse files
authored
Increase default maxAllowedPacket size. (#1411)
64MiB is same to MySQL 8.0.
1 parent d83ecdc commit f0e16c6

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Please keep in mind, that param values must be [url.QueryEscape](https://golang.
282282
##### `maxAllowedPacket`
283283
```
284284
Type: decimal number
285-
Default: 4194304
285+
Default: 64*1024*1024
286286
```
287287

288288
Max packet size allowed in bytes. The default value is 4 MiB and should be adjusted to match the server settings. `maxAllowedPacket=0` can be used to automatically fetch the `max_allowed_packet` variable from server *on every connection*.

const.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package mysql
1010

1111
const (
1212
defaultAuthPlugin = "mysql_native_password"
13-
defaultMaxAllowedPacket = 4 << 20 // 4 MiB
13+
defaultMaxAllowedPacket = 64 << 20 // 64 MiB. See https://github.com/go-sql-driver/mysql/issues/1355
1414
minProtocolVersion = 10
1515
maxPacketSize = 1<<24 - 1
1616
timeFormat = "2006-01-02 15:04:05.999999"

errors.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var (
2727
ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+")
2828
ErrPktSync = errors.New("commands out of sync. You can't run this command now")
2929
ErrPktSyncMul = errors.New("commands out of sync. Did you run multiple statements at once?")
30-
ErrPktTooLarge = errors.New("packet for query is too large. Try adjusting the 'max_allowed_packet' variable on the server")
30+
ErrPktTooLarge = errors.New("packet for query is too large. Try adjusting the `Config.MaxAllowedPacket`")
3131
ErrBusyBuffer = errors.New("busy buffer")
3232

3333
// errBadConnNoWrite is used for connection errors where nothing was sent to the database yet.

0 commit comments

Comments
 (0)