# Go-MySQL-Driver
A MySQL-Driver for Go's [database/sql](https://golang.org/pkg/database/sql/) package
![Go-MySQL-Driver logo](https://raw.github.com/wiki/go-sql-driver/mysql/gomysql_m.png "Golang Gopher holding the MySQL Dolphin")
---------------------------------------
* [Features](#features)
* [Requirements](#requirements)
* [Installation](#installation)
* [Usage](#usage)
* [DSN (Data Source Name)](#dsn-data-source-name)
* [Password](#password)
* [Protocol](#protocol)
* [Address](#address)
* [Parameters](#parameters)
* [Examples](#examples)
* [Connection pool and timeouts](#connection-pool-and-timeouts)
* [context.Context Support](#contextcontext-support)
* [ColumnType Support](#columntype-support)
* [LOAD DATA LOCAL INFILE support](#load-data-local-infile-support)
* [time.Time support](#timetime-support)
* [Unicode support](#unicode-support)
* [Testing / Development](#testing--development)
* [License](#license)
---------------------------------------
## Features
* Lightweight and [fast](https://github.com/go-sql-driver/sql-benchmark "golang MySQL-Driver performance")
* Native Go implementation. No C-bindings, just pure Go
* Connections over TCP/IPv4, TCP/IPv6, Unix domain sockets or [custom protocols](https://godoc.org/github.com/go-sql-driver/mysql#DialFunc)
* Automatic handling of broken connections
* Automatic Connection Pooling *(by database/sql package)*
* Supports queries larger than 16MB
* Full [`sql.RawBytes`](https://golang.org/pkg/database/sql/#RawBytes) support.
* Intelligent `LONG DATA` handling in prepared statements
* Secure `LOAD DATA LOCAL INFILE` support with file Whitelisting and `io.Reader` support
* Optional `time.Time` parsing
* Optional placeholder interpolation
## Requirements
* Go 1.8 or higher. We aim to support the 3 latest versions of Go.
* MySQL (4.1+), MariaDB, Percona Server, Google CloudSQL or Sphinx (2.2.3+)
---------------------------------------
## Installation
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:
```bash
$ go get -u github.com/go-sql-driver/mysql
```
Make sure [Git is installed](https://git-scm.com/downloads) on your machine and in your system's `PATH`.
## Usage
_Go MySQL Driver_ is an implementation of Go's `database/sql/driver` interface. You only need to import the driver and can use the full [`database/sql`](https://golang.org/pkg/database/sql/) API then.
Use `mysql` as `driverName` and a valid [DSN](#dsn-data-source-name) as `dataSourceName`:
```go
import "database/sql"
import _ "github.com/go-sql-driver/mysql"
db, err := sql.Open("mysql", "user:password@/dbname")
```
[Examples are available in our Wiki](https://github.com/go-sql-driver/mysql/wiki/Examples "Go-MySQL-Driver Examples").
### DSN (Data Source Name)
The Data Source Name has a common format, like e.g. [PEAR DB](http://pear.php.net/manual/en/package.database.db.intro-dsn.php) uses it, but without type-prefix (optional parts marked by squared brackets):
```
[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN]
```
A DSN in its fullest form:
```
username:password@protocol(address)/dbname?param=value
```
Except for the databasename, all values are optional. So the minimal DSN is:
```
/dbname
```
If you do not want to preselect a database, leave `dbname` empty:
```
/
```
This has the same effect as an empty DSN string:
```
```
Alternatively, [Config.FormatDSN](https://godoc.org/github.com/go-sql-driver/mysql#Config.FormatDSN) can be used to create a DSN string by filling a struct.
#### Password
Passwords can consist of any character. Escaping is **not** necessary.
#### Protocol
See [net.Dial](https://golang.org/pkg/net/#Dial) for more information which networks are available.
In general you should use an Unix domain socket if available and TCP otherwise for best performance.
#### Address
For TCP and UDP networks, addresses have the form `host[:port]`.
If `port` is omitted, the default port will be used.
If `host` is a literal IPv6 address, it must be enclosed in square brackets.
The functions [net.JoinHostPort](https://golang.org/pkg/net/#JoinHostPort) and [net.SplitHostPort](https://golang.org/pkg/net/#SplitHostPort) manipulate addresses in this form.
For Unix domain sockets the address is the absolute path to the MySQL-Server-socket, e.g. `/var/run/mysqld/mysqld.sock` or `/tmp/mysql.sock`.
#### Parameters
*Parameters are case-sensitive!*
Notice that any of `true`, `TRUE`, `True` or `1` is accepted to stand for a true boolean value. Not surprisingly, false can be specified as any of: `false`, `FALSE`, `False` or `0`.
##### `allowAllFiles`
```
Type: bool
Valid Values: true, false
Default: false
```
`allowAllFiles=true` disables the file Whitelist for `LOAD DATA LOCAL INFILE` and allows *all* files.
[*Might be insecure!*](http://dev.mysql.com/doc/refman/5.7/en/load-data-local.html)
##### `allowCleartextPasswords`
```
Type: bool
Valid Values: true, false
Default: false
```
`allowCleartextPasswords=true` allows using the [cleartext client side plugin](http://dev.mysql.com/doc/en/cleartext-authentication-plugin.html) if required by an account, such as one defined with the [PAM authentication plugin](http://dev.mysql.com/doc/en/pam-authentication-plugin.html). Sending passwords in clear text may be a security problem in some configurations. To avoid problems if there is any possibility that the password would be intercepted, clients should connect to MySQL Server using a method that protects the password. Possibilities include [TLS / SSL](#tls), IPsec, or a private network.
##### `allowNativePasswords`
```
Type: bool
Valid Values: true, false
Default: true
```
`allowNativePasswords=false` disallows the usage of MySQL native password method.
##### `allowOldPasswords`
```
Type: bool
Valid Values: true, false
Default: false
```
`allowOldPasswords=true` allows the usage of the insecure old password method. This should be avoided, but is necessary in some cases. See also [the old_passwords wiki page](https://github.com/go-sql-driver/mysql/wiki/old_passwords).
##### `charset`
```
Type: string
Valid Values: <name>
Default: none
```
Sets the charset used for client-server interaction (`"SET NAMES <value>"`). If multiple charsets are set (separated by a comma), the following charset is used if setting the charset failes. This enables for example support for `utf8mb4` ([introduced in MySQL 5.5.3](http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html)) with fallback to `utf8` for older servers (`charset=utf8mb4,utf8`).
Usage of the `charset` parameter is discouraged because it issues additional queries to the server.
Unless you need the fallback behavior, please use `collation` instead.
##### `collation`
```
Type: string
Valid Values: <name>
Default: utf8_general_ci
```
Sets the collation used for client-server interaction on connection. In contrast to `charset`, `collation` does not issue additional queries. If the specified collation is unavailable on the target server, the connection will fail.
A list of valid charsets for a server is retrievable with `SHOW COLLATION`.
##### `clientFoundRows`
```
Type: bool
Valid Values: true, false
Default: false
```
`clientFoundRows=true` causes an UPDATE to return the number of matching rows instead of the number of rows changed.
##### `columnsWithAlias`
```
Type: bool
Valid Values: true, false
Default: false
```
When `columnsWithAlias` is true, calls to `sql.Rows.Columns()` will return the table alias and the column name separated by a dot. For example:
```
SELECT u.id FROM users as u
```
will return `u.id` instead of just `id` if `columnsWithAlias=true`.
#
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码 【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码【毕业设计】基于异步架构的图片管理系统后端设计和实现项目源码
资源推荐
资源详情
资源评论
收起资源包目录
基于异步架构的图片管理系统后端设计和实现项目源码.zip (853个子文件)
AUTHORS 3KB
AUTHORS 484B
AUTHORS 174B
AUTHORS 173B
AUTHORS 173B
zstd_v07.c 180KB
zstd_v06.c 161KB
zstd_v05.c 151KB
zstd_compress.c 150KB
zstd_v04.c 133KB
zstd_v02.c 124KB
zstd_decompress.c 122KB
zstd_v03.c 111KB
zstdmt_compress.c 79KB
zstd_v01.c 69KB
divsufsort.c 53KB
huf_decompress.c 45KB
zdict.c 43KB
zstd_opt.c 39KB
zstd_lazy.c 36KB
cover.c 33KB
fse_compress.c 32KB
huf_compress.c 32KB
xxhash.c 28KB
zstd_ldm.c 25KB
zstd_double_fast.c 15KB
fse_decompress.c 11KB
zstd_fast.c 11KB
pool.c 9KB
entropy_common.c 9KB
zbuff_compress.c 5KB
zstd_common.c 3KB
error_private.c 3KB
zbuff_decompress.c 2KB
threading.c 2KB
gccgo_c.c 1KB
zbuff_common.c 1003B
CONTRIBUTORS 1KB
CONTRIBUTORS 171B
CONTRIBUTORS 170B
CONTRIBUTORS 170B
dockerfile 362B
dockerfile 350B
dockerfile 307B
dockerfile 303B
dockerfile 283B
刘曦光毕业论文.docx 939KB
zerrors_linux_ppc64le.go 127KB
zerrors_linux_ppc64.go 127KB
zerrors_linux_sparc64.go 127KB
zerrors_linux_s390x.go 127KB
zerrors_linux_mips64le.go 125KB
zerrors_linux_mipsle.go 125KB
zerrors_linux_mips64.go 125KB
zerrors_linux_mips.go 125KB
zerrors_linux_arm.go 124KB
zerrors_linux_amd64.go 124KB
zerrors_linux_386.go 124KB
zerrors_linux_arm64.go 124KB
zerrors_linux_riscv64.go 123KB
zsyscall_windows.go 90KB
zerrors_darwin_amd64.go 73KB
zerrors_darwin_arm64.go 73KB
zerrors_darwin_386.go 73KB
zerrors_darwin_arm.go 73KB
zerrors_netbsd_386.go 72KB
zerrors_openbsd_amd64.go 72KB
zerrors_netbsd_arm64.go 72KB
zerrors_netbsd_amd64.go 72KB
zerrors_netbsd_arm.go 72KB
zerrors_freebsd_arm.go 70KB
zerrors_freebsd_arm64.go 70KB
zerrors_freebsd_amd64.go 70KB
zerrors_freebsd_386.go 70KB
zerrors_openbsd_arm.go 68KB
zerrors_openbsd_386.go 68KB
zsyscall_darwin_amd64.go 67KB
zerrors_dragonfly_amd64.go 67KB
zsyscall_darwin_386.go 67KB
zsyscall_darwin_arm.go 66KB
zsyscall_darwin_arm64.go 66KB
commands.go 63KB
zsyscall_linux_ppc64le.go 59KB
zsyscall_linux_ppc64.go 59KB
zerrors_solaris_amd64.go 58KB
zsyscall_linux_mipsle.go 58KB
zsyscall_linux_mips.go 58KB
zsyscall_linux_amd64.go 57KB
zsyscall_linux_sparc64.go 57KB
zsyscall_linux_mips64le.go 57KB
zsyscall_linux_mips64.go 57KB
zsyscall_linux_arm.go 57KB
zsyscall_linux_arm64.go 54KB
zsyscall_solaris_amd64.go 54KB
zsyscall_linux_riscv64.go 54KB
zsyscall_linux_386.go 53KB
zsyscall_linux_s390x.go 53KB
zerrors_aix_ppc64.go 52KB
zerrors_aix_ppc.go 52KB
ztypes_linux_s390x.go 51KB
共 853 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
小正太浩二
- 粉丝: 218
- 资源: 5915
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功