You need to enable JavaScript to run this app.
RDS for MySQL

RDS for MySQL

Copy page
Download PDF
Go SDK
Initializing the client
Copy page
Download PDF
Initializing the client
The MySQL Go SDK supports initializing the client through a session. A MySQL client created through a session reuses underlying HTTP/HTTPS resources (connections or requests). When you need to initialize multiple clients for operations, creating them through a session can improve client performance. This article describes how to initialize the client through a session.​
Prerequisites​
  • A Volcano Engine account has been registered with real name authentication completed. For specific steps, refer to Create account and Verify account.​
  • The Access Key ID (AK) and Secret Access Key (SK) of the account have been obtained. For instructions, refer to View AKSK information.​
  • The regions supported by RDS for MySQL have been obtained. Refer to Service Address.​
Initializing the client​
Use the following code to initialize the client.​
​
package main​
​
import (​
"fmt"​
"os"​
​
"github.com/volcengine/volcengine-go-sdk/service/rdsmysqlv2"​
"github.com/volcengine/volcengine-go-sdk/volcengine"​
"github.com/volcengine/volcengine-go-sdk/volcengine/credentials"​
"github.com/volcengine/volcengine-go-sdk/volcengine/session"​
)​
​
func main() {​
var (​
ak string​
sk string​
region string​
config *volcengine.Config​
sess *session.Session​
client *rdsmysqlv2.RDSMYSQLV2​
err error​
)​
​
ak = "Your AK"​
sk = "Your SK"​
region = "Your Region"​
config = volcengine.NewConfig().WithCredentials(credentials.NewStaticCredentials(ak, sk, "")).WithRegion(region)​
sess, err = session.NewSession(config)​
if err != nil {​
fmt.Printf("Failed to create session, err: %v\n", err)​
os.Exit(1)​
}​
client = rdsmysqlv2.New(sess)​
}​
​
​
​
Last updated: 2025.12.04 11:25:46