Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MySQL 8.0 and support for TLS/SSL for both Server and Client #312

Merged
merged 28 commits into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1a4c540
new testing env with docker-compose for interation with MySQl 5.7, 8.0
jianjunxie Aug 12, 2018
c04a594
remove unused code
jianjunxie Aug 13, 2018
fc03190
update
michael2008 Aug 13, 2018
73c0ccc
add support for caching_sha2_password and sha256_password, still has …
michael2008 Aug 14, 2018
8d9f198
caching_sha2_password and sha256_password passed tests on MySQL 5.5 t…
michael2008 Aug 15, 2018
f499d71
fix typo
michael2008 Aug 15, 2018
3a7a3c1
ready for test and debug
michael2008 Aug 17, 2018
132892e
update vendor
michael2008 Aug 17, 2018
339542d
refactor to compatible with MySQL server: add credential provider
michael2008 Aug 17, 2018
596a8a1
update
jianjunxie Aug 17, 2018
0c8fd9d
update: add test cases
jianjunxie Aug 18, 2018
1d17f87
more tests
jianjunxie Aug 19, 2018
d8c39ba
more tests
jianjunxie Aug 19, 2018
38a02a2
add content to README
jianjunxie Aug 19, 2018
175e49b
cleanup the code
jianjunxie Aug 19, 2018
11d31d6
empty cache for testing
jianjunxie Aug 19, 2018
6c1264d
fix a race condition for Server conf
jianjunxie Aug 19, 2018
2cb184e
fix rare RSA decryption error when read packet wrong
michael2008 Aug 20, 2018
91dd27b
test server against MySQL native clients (MySQL 5.7 & 8.0); resolve c…
michael2008 Aug 20, 2018
408fef7
fix test instance
michael2008 Aug 20, 2018
aefe5e7
Merge branch 'master' into master
siddontang Aug 21, 2018
181d73a
update according to reviews
jianjunxie Aug 22, 2018
fb4f72a
fix the import in example
jianjunxie Aug 22, 2018
be1f7e6
move all the test RSA keys to the test_util mod
jianjunxie Aug 22, 2018
d8791c8
make the example server handle error connection instead of panic
jianjunxie Aug 22, 2018
670b057
Merge branch 'master' into master
IANTHEREAL Oct 25, 2018
738bef3
Merge branch 'master' into master
michael2008 Dec 20, 2018
b08b5fa
change to client.Conn's func SetTLSConfig()
michael2008 Dec 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@

[[constraint]]
name = "github.com/BurntSushi/toml"
version = "0.3.0"
version = "v0.3.0"

[[constraint]]
name = "github.com/go-sql-driver/mysql"
version = "1.3.0"
branch = "master"

[[constraint]]
branch = "master"
name = "github.com/juju/errors"

[[constraint]]
name = "github.com/satori/go.uuid"
version = "1.1.0"
version = "v1.2.0"

[[constraint]]
name = "github.com/shopspring/decimal"
version = "1.0.0"
version = "v1.1.0"

[[constraint]]
branch = "master"
Expand Down
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,16 @@ import (
"github.com/siddontang/go-mysql/client"
)

// Connect MySQL at 127.0.0.1:3306, with user root, an empty passowrd and database test
// Connect MySQL at 127.0.0.1:3306, with user root, an empty password and database test
conn, _ := client.Connect("127.0.0.1:3306", "root", "", "test")

// Or to use SSL/TLS connection if MySQL server supports TLS
//conn, _ := client.Connect("127.0.0.1:3306", "root", "", "test", func(c *Conn) {c.UseSSL(true)})

// or to set your own client-side certificates for identity verification for security
//tlsConfig := NewClientTLSConfig(caPem, certPem, keyPem, false, "your-server-name")
//conn, _ := client.Connect("127.0.0.1:3306", "root", "", "test", func(c *Conn) {c.SetTLSConfig(tlsConfig)})

conn.Ping()

// Insert
Expand All @@ -157,10 +164,17 @@ v, _ := r.GetInt(0, 0)
v, _ = r.GetIntByName(0, "id")
```

Tested MySQL versions for the client include:
- 5.5.x
- 5.6.x
- 5.7.x
- 8.0.x

## Server

Server package supplies a framework to implement a simple MySQL server which can handle the packets from the MySQL client.
You can use it to build your own MySQL proxy.
You can use it to build your own MySQL proxy. The server connection is compatible with MySQL 5.5, 5.6, 5.7, and 8.0 versions,
so that most MySQL clients should be able to connect to the Server without modifications.

### Example

Expand All @@ -174,14 +188,14 @@ l, _ := net.Listen("tcp", "127.0.0.1:4000")

c, _ := l.Accept()

// Create a connection with user root and an empty passowrd
// We only an empty handler to handle command too
// Create a connection with user root and an empty password.
// You can use your own handler to handle command here.
conn, _ := server.NewConn(c, "root", "", server.EmptyHandler{})

for {
conn.HandleCommand()
}
```
```

Another shell

Expand All @@ -190,6 +204,15 @@ mysql -h127.0.0.1 -P4000 -uroot -p
//Becuase empty handler does nothing, so here the MySQL client can only connect the proxy server. :-)
```

> ```NewConn()``` will use default server configurations:
> 1. automatically generate default server certificates and enable TLS/SSL support.
> 2. support three mainstream authentication methods **'mysql_native_password'**, **'caching_sha2_password'**, and **'sha256_password'**
> and use **'mysql_native_password'** as default.
> 3. use an in-memory user credential provider to store user and password.
>
> To customize server configurations, use ```NewServer()``` and create connection via ```NewCustomizedConn()```.


## Failover

Failover supports to promote a new master and let other slaves replicate from it automatically when the old master was down.
Expand Down
Loading