Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

MySQL SDK by Go

License

NotificationsYou must be signed in to change notification settings

vczyh/mysql-protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"))iferr!=nil {// handle error}iferr:=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

namedefaultdescription
WithVersion()""Version identifier.
WithDefaultAuthMethod()mysql_native_passwordAuthentication plugin.
WithSHA2Cache()DefaultSHA2Cachecaching_sha2_password caching function implement.
WithLogger()DefaultLoggerImplement of logger write all messages to.
WithUseSSL()falseWhether to open SSL/TLS. Use automatically generated key and certificates if it's true andWithSSLCA()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. IfWithCertsDir() not empty, write those files to the directory, otherwise read them instead of generating.
WithSSLCA()automatically generateThe path name of the Certificate Authority (CA) certificate file in PEM format. The file contains a list of trusted SSL Certificate Authorities.
WithSSLCert()automatically generateThe path name of the server SSL public key certificate file in PEM format.
WithSSLKey()automatically generateThe 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. IfWithRSAKeysDir() not empty, write those files to the directory, otherwise read them instead of generating. The key pair is used bysha256_password whenWithSHA256PasswordPrivateKeyPath() andWithSHA256PasswordPublicKeyPath() are not specified, or used bycaching_sha2_password whenWithCachingSHA2PasswordPrivateKeyPath() andWithCachingSHA2PasswordPublicKeyPath()are not specified.
WithCachingSHA2PasswordPrivateKeyPath()automatically generateIts value is the path name of the RSA private key file for thecaching_sha2_password authentication plugin.
WithCachingSHA2PasswordPublicKeyPath()automatically generateIts value is the path name of the RSA public key file for thecaching_sha2_password authentication plugin.
WithSHA256PasswordPrivateKeyPath()automatically generateIts value is the path name of the RSA private key file for thesha256_password authentication plugin.
WithSHA256PasswordPublicKeyPath()automatically generateIts value is the path name of the RSA public key file for thesha256_password authentication plugin.

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp