This guide walks you through the steps to create, configure, and connect to a PolarDB for MySQL edge cluster running on ENS (Edge Node Service).
Supported regions
PolarDB for MySQL on ENS is currently available in the following regions only:
-
Haikou Telecom
-
Türkiye (Istanbul)-1
-
Macao (China)-2
-
Vietnam (Hanoi)-3
Prerequisites
Before you begin, make sure you have:
-
An Alibaba Cloud account with ENS activated. If you have not used ENS before, complete the ENS activation process first.
-
Access to the ENS console and PolarDB console.
Step 1: Create an ENS network
Your edge cluster must reside within an ENS network.
-
Go to the ENS console.
-
In the left navigation pane, choose VPC Management > Networks.
-
Click Create Network.
-
On the Create Network page, configure the VPCs and vSwitches for the region (node) where you plan to deploy your cluster.
Step 2: Create an edge cluster
-
Go to the edge cluster purchase page.
-
Configure the following parameters. For this quick start, you can leave all other settings at their default values.
Required parameters
| Parameter | Recommended value | Description |
|---|---|---|
| Billing method | Subscription (Pre-paid) | The only supported billing method for edge clusters. Suited for stable, long-term workloads. |
| Edge primary data center | Same region as your ENS network | The region (node) where the cluster resides. Must match the ENS network you created in Step 1 to enable private network connectivity. |
| Network and zone | VPC and vSwitch from Step 1 | Select the VPC and vSwitch you created in Step 1. |
Optional parameters to review
| Parameter | Description |
|---|---|
| Compatibility | The MySQL-compatible version for the cluster. MySQL 8.0.2 is fully compatible with community MySQL 8.0.18 and earlier. MySQL 8.0.1 is fully compatible with community MySQL 8.0.13 and earlier. |
| Database edition | Dedicated: each cluster uses its allocated CPUs exclusively, providing more stable performance. General-purpose: clusters on the same server share idle CPUs, offering better cost-effectiveness. For a comparison, see How to choose between General-purpose and Dedicated specifications. |
| Specification | The node CPU and memory. Select the size that meets your performance needs. |
| Nodes | Defaults to 2 nodes: one read/write node (primary node) and one read-only node. The read/write node handles write operations and some reads. Read-only nodes offload reads from the primary and provide high availability. You can also add a column store read-only node, which is a dedicated node for the In-Memory Column Index (IMCI) feature. It uses columnar storage to accelerate analytical queries (OLAP) and offload the primary and read-only nodes. Note
Once you purchase a cluster with read-only nodes, you cannot reduce the read-only node count to 0. To do so, purchase a new cluster and migrate the data using DTS (Data Transmission Service) or the major version upgrade feature. |
| Storage type | PL0 ESSD: performance level 0. PL1 ESSD: performance level 1, with 5 times the IOPS of PL0 ESSD. |
| Storage capacity | Defaults to 100 GB. |
Step 3: Create a database account
-
Go to the PolarDB console for edge clusters and select your newly created edge cluster.
-
In the left menu, click Settings and Management > Accounts.
-
Click Create Account. Choose a Privileged Account or Standard Account based on your security requirements. For details on permissions, see Account permissions.
Step 4: Get the cluster endpoint address
-
In the PolarDB console for edge clusters, open your cluster's details page.
-
In the left menu, click Database Connections.
-
Copy the Cluster Endpoint address. This endpoint load-balances connections across all nodes in the cluster. The default port is
3306.
Step 5: Connect to your database
Use the cluster endpoint and database account from the previous steps to connect. The following examples cover three common connection methods.
Use a client
This example uses MySQL Workbench 8.0.29. Other MySQL-compatible clients follow the same steps.
-
Install MySQL Workbench. Download it from the MySQL Workbench download page.
-
Open MySQL Workbench and choose Database > Connect to Database.
-
Enter the connection details and click OK.
| Parameter | Description | Example |
|---|---|---|
| Hostname | The cluster endpoint. See Database connection. | pc-2***.rwlb.rds.aliyuncs.com |
| Port | The port for the cluster endpoint. Default is 3306. | 3306 |
| Username | The database account. See Create a database account. | polardb_mysql_user |
| Password | The password for the database account. | Pass***233 |
Use the CLI
Run the following command if the MySQL client is installed on your server:
Syntax:
mysql -h <Endpoint> -P <Port> -u <Account> -p<Password>
Example:
mysql -h pc-2***.rwlb.rds.aliyuncs.com -P3306 -upolardb_mysql_user -pPass***233
| Parameter | Description | Example |
|---|---|---|
-h |
The cluster endpoint. | pc-2***.rwlb.rds.aliyuncs.com |
-P |
The port number. Omit if using the default port 3306. | 3306 |
-u |
The database account. | polardb_mysql_user |
-p |
The password. Do not add a space between -p and the password. If omitted, you are prompted to enter the password when Enter password appears. |
Pass***233 |
Use an application
Connecting to a PolarDB for MySQL cluster works the same as connecting to any MySQL database — replace the endpoint, port, account, and password with your cluster's values.
Java
This example uses a Maven project with the MySQL JDBC driver.
-
Add the MySQL JDBC driver dependency to your
pom.xml:<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.27</version> </dependency> -
Connect to the cluster. Replace
<HOST>,<USER>,<PASSWORD>,<DATABASE>,<YOUR_TABLE_NAME>, and<YOUR_TABLE_COLUMN_NAME>with your values.import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class DatabaseConnection { public DatabaseConnection() { } public static void main(String[] args) { // Cluster endpoint, port, and database name String url = "jdbc:mysql://<HOST>:3306/<DATABASE>?useSSL=false&serverTimezone=UTC"; // Database account String user = "<USER>"; // Password for the database account String password = "<PASSWORD>"; try { Class.forName("com.mysql.cj.jdbc.Driver"); Connection conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); // Query the specified table ResultSet rs = stmt.executeQuery("SELECT * FROM `<YOUR_TABLE_NAME>`"); while(rs.next()) { // Print the specified column value System.out.println(rs.getString("<YOUR_TABLE_COLUMN_NAME>")); } rs.close(); stmt.close(); conn.close(); } catch (Exception var7) { var7.printStackTrace(); } } }
Python
This example uses Python 3 with the PyMySQL library.
-
Install PyMySQL:
pip3 install PyMySQL -
Connect to the cluster. Replace
<HOST>,<USER>,<PASSWORD>,<DATABASE>, and<YOUR_TABLE_NAME>with your values.import pymysql # Connection parameters host = '<HOST>' # Cluster endpoint port = 3306 # Default port user = '<USER>' # Database account password = '<PASSWORD>' # Password for the database account database = '<DATABASE>' # Name of the database to connect to try: # Establish a connection connection = pymysql.connect( host=host, port=port, user=user, passwd=password, db=database ) with connection.cursor() as cursor: # Execute a query sql = "SELECT * FROM '<YOUR_TABLE_NAME>'" cursor.execute(sql) # Print results results = cursor.fetchall() for row in results: print(row) finally: # Close the connection if 'connection' in locals() and connection.open: connection.close()
Go
This example uses Go 1.23.0 with the database/sql package and go-sql-driver/mysql driver.
-
Install the driver:
go get -u github.com/go-sql-driver/mysql -
Connect to the cluster. Replace
<HOST>,<USER>,<PASSWORD>,<DATABASE>, and<YOUR_TABLE_NAME>with your values.package main import ( "database/sql" "fmt" "log" _ "github.com/go-sql-driver/mysql" ) func main() { // Connection parameters dbHost := "<HOST>" // Cluster endpoint dbPort := "3306" // Default port dbUser := "<USER>" // Database account dbPass := "<PASSWORD>" // Password for the database account dbName := "<DATABASE>" // Name of the database to connect to // Build the DSN (Data Source Name) dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", dbUser, dbPass, dbHost, dbPort, dbName) // Open a connection db, err := sql.Open("mysql", dsn) if err != nil { log.Fatalf("Failed to connect to database: %v", err) } defer db.Close() // Verify the connection err = db.Ping() if err != nil { log.Fatalf("Failed to ping database: %v", err) } // Print the database version var result string err = db.QueryRow("SELECT VERSION()").Scan(&result) if err != nil { log.Fatalf("Failed to execute query: %v", err) } fmt.Printf("Connected to database, version: %s\n", result) // Execute a query rows, err := db.Query("SELECT * FROM '<YOUR_TABLE_NAME>'") if err != nil { log.Fatalf("Failed to execute query: %v", err) } defer rows.Close() }
What's next
-
Account permissions — manage database account types and access control
-
Database connection — explore additional connection options and endpoint types
-
In-Memory Column Index (IMCI) — accelerate analytical queries with columnar storage on a column store read-only node
-
How to choose between General-purpose and Dedicated specifications — select the right database edition for your workload