Giter VIP home page Giter VIP logo

mysql-protocol's Introduction

MySQL Protocol

MySQL SDK by Go.

The following has been implemented:

Install

go get github.com/vczyh/mysql-protocol

Client

conn, err := client.CreateConnection(
    client.WithHost("10.0.44.59"),
    client.WithPort(3306),
    client.WithUser("root"),
    client.WithPassword("Unicloud@1221"))

if err != nil {
	// handle error
}

if err := conn.Ping(); err != nil {
	// handle error
}

Server

userProvider := server.NewMemoryUserProvider()
// user1
_ = userProvider.Create(&server.CreateUserRequest{
  User:        "root",
  Host:        "%",
  Password:    "123456",
  Method:      auth.SHA256Password,
  TLSRequired: false,
})
// user2
_ = userProvider.Create(&server.CreateUserRequest{
  User:        "root2",
  Host:        "%",
  Password:    "123456",
  Method:      auth.CachingSha2Password,
  TLSRequired: false,
})

srv := server.NewServer(
  userProvider,
  server.NewDefaultHandler(),
  server.WithPort(3306),
)

_ = srv.Start()

Flags

name default description
WithVersion() "" Version identifier.
WithDefaultAuthMethod() mysql_native_password Authentication plugin.
WithSHA2Cache() DefaultSHA2Cache caching_sha2_password caching function implement.
WithLogger() DefaultLogger Implement of logger write all messages to.
WithUseSSL() false Whether to open SSL/TLS. Use automatically generated key and certificates if it's true and WithSSLCA() WithSSLCert() WithSSLKey()are not specified.
WithCertsDir() "" At startup, the server automatically generates server-side and client-side SSL/TLS certificate and key files, include CA certificate and key file. Default don't write them to local file system. If WithCertsDir() not empty, write those files to the directory, otherwise read them instead of generating.
WithSSLCA() automatically generate The path name of the Certificate Authority (CA) certificate file in PEM format. The file contains a list of trusted SSL Certificate Authorities.
WithSSLCert() automatically generate The path name of the server SSL public key certificate file in PEM format.
WithSSLKey() automatically generate The path name of the server SSL private key file in PEM format.
WithRSAKeysDir() "" At startup, the server automatically generates private and public key. Default don't write them to local file system. If WithRSAKeysDir() not empty, write those files to the directory, otherwise read them instead of generating. The key pair is used by sha256_password when WithSHA256PasswordPrivateKeyPath() and WithSHA256PasswordPublicKeyPath() are not specified, or used by caching_sha2_password when WithCachingSHA2PasswordPrivateKeyPath() and WithCachingSHA2PasswordPublicKeyPath()are not specified.
WithCachingSHA2PasswordPrivateKeyPath() automatically generate Its value is the path name of the RSA private key file for the caching_sha2_password authentication plugin.
WithCachingSHA2PasswordPublicKeyPath() automatically generate Its value is the path name of the RSA public key file for the caching_sha2_password authentication plugin.
WithSHA256PasswordPrivateKeyPath() automatically generate Its value is the path name of the RSA private key file for the sha256_password authentication plugin.
WithSHA256PasswordPublicKeyPath() automatically generate Its value is the path name of the RSA public key file for the sha256_password authentication plugin.

mysql-protocol's People

Contributors

vczyh avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.