This topic describes how to use Power BI to connect to an AnalyticDB for MySQL cluster for real-time data analysis.
Prerequisites
You have installed Power BI.
NoteThe steps in this topic use Power BI Desktop 2.143.878.0 in English.
If you want to connect to an AnalyticDB for MySQL cluster over the internet, you must first request a public endpoint.
If you connect to a Spark Java Database Connectivity (JDBC) endpoint, you must also create an interactive Spark resource group.
Connect to an ADB MySQL endpoint using Power BI
Use a custom connector to connect (recommended)
You can use a custom connector or the built-in MySQL connector in Power BI to access AnalyticDB for MySQL data in import mode. You can also use a custom connector to access AnalyticDB for MySQL data in direct query mode. We recommend that you use a custom connector to connect to an AnalyticDB for MySQL cluster to support different data access modes.
Step 1: Install the MySQL ODBC driver
Download and install the Microsoft Visual C++ 2010 Service Pack 1 Redistributable Package MFC.
Download and install version 5.1.13 of the MySQL ODBC Driver.
Open ODBC Data Source Administrator (64-bit). On the Drivers tab, check whether the MySQL ODBC Driver is installed.
Step 2: Install the AnalyticDB for MySQL connector
Download the AnalyticDB.MySQL.mez connector.
Move the AnalyticDB.MySQL.mez connector to the Custom Connectors folder in the Power BI directory. The default path is `[Documents]\Power BI Desktop`. If the Custom Connectors folder does not exist, create it.
Important`[Documents]` refers to the Documents folder of the current user account. For example, the default path for the Administrator account is `C:\Users\Administrator\Documents\Power BI Desktop`.
Each user account has its own Documents folder. Power BI can load connectors only from the current user's folder. Therefore, you must install and maintain connectors for each account independently.
Open Power BI and click .

Click Security. In the Data Extensions section, select (Not Recommended) Allow any extension to load without validation or warning and click OK.

In the Change Requires Restart dialog box, click OK. Then, restart Power BI.
Step 3: Use Power BI to connect to AnalyticDB for MySQL
Open Power BI and click Get data from another source.

In the Get Data dialog box, select AnalyticDB MySQL(Beta)(Custom) and click Connect.

In the Connecting to a third-party service dialog box, click Continue.

In the AnalyticDB MySQL database dialog box, configure the parameters.

Parameter description:
Parameter
Required
Description
Server
Yes
The endpoint and port of the AnalyticDB for MySQL cluster. The format is
<Endpoint>:Port.Endpoint:
If Power BI is installed on ECS, and the ECS and the AnalyticDB for MySQL cluster are in the same VPC, enter the VPC address.
If Power BI is installed on a local server, enter the public endpoint.
The port is fixed at 3306.
Database
No
The name of the database in the AnalyticDB for MySQL cluster.
Connection timeout in seconds
No
The timeout period for connecting to the AnalyticDB for MySQL cluster. Unit: seconds (s).
Read timeout in seconds
No
The maximum time allowed for a read operation. Unit: seconds (s).
Write timeout in seconds
No
The maximum time allowed for a write operation. Unit: seconds (s).
Don't cache results of forward-only cursors
No
Power BI does not cache query results when it uses forward-only cursors to query data.
Force use of forward-only cursors
No
Power BI is forced to use forward-only cursors when it runs queries.
Native query
No
The SQL query statement. If you leave this parameter empty, all tables in the AnalyticDB for MySQL cluster are listed in the Navigator dialog box in Step 6.
Data Connectivity mode
Yes
The data connection mode. Valid values:
Import: import mode.
DirectQuery: direct query mode.
In the AnalyticDB MySQL dialog box, configure the parameters and click Connect.

Parameter description:
Parameter
Description
User name
The database account of the AnalyticDB for MySQL cluster.
Password
The password of the database account for the AnalyticDB for MySQL cluster.
In the Navigator dialog box, select the target data table, preview the data in the pane on the right, and then click Load.
After the configuration is complete, you can start data analysis on the data source. For more information, see the official Power BI documentation.

Use the built-in MySQL connector of Power BI to connect
Download and install the MySQL Connector.
Open Power BI and click Get data from another source.

Select MySQL database and click Connect.
NotePower BI automatically detects whether the MySQL Connector is installed on your system. If it is not installed, follow the prompts to install it.

In the MySQL database dialog box, configure the parameters and click OK.

Parameter description:
Parameter
Required
Description
Server
Yes
The endpoint and port of the AnalyticDB for MySQL cluster. The format is
<Endpoint>:Port.If Power BI is installed on ECS, and the ECS and the AnalyticDB for MySQL cluster are in the same VPC, enter the VPC address.
If Power BI is installed on a local server, enter the public endpoint.
Database
No
The name of the database in the AnalyticDB for MySQL cluster.
In the MySQL Database dialog box, click the Database tab, configure the parameters, and then click Connect.

Parameter description:
Parameter
Required
Description
User name
Yes
The database account of the AnalyticDB for MySQL cluster.
Password
Yes
The password of the database account for the AnalyticDB for MySQL cluster.
In the Encryption Support dialog box, click OK.

In the Navigator dialog box, select the target data table, preview the data in the pane on the right, and then click Load.
After you complete the configuration, you can start data analytics on this data source. For more information, see the official Power BI documentation.

Connect to a Spark JDBC endpoint using Power BI
Precautions
After you connect to a Spark JDBC endpoint using Power BI, you can only read data from and write data to tables that use the XUANWU table engine. Tables that use the XUANWU_V2 table engine are not supported.
Procedure
Download a driver.
Power BI can connect to an interactive Spark resource group using the Microsoft Spark ODBC Driver or the Simba Spark ODBC Driver. Download the driver that meets your business needs.
Create a data source.
Open ODBC Data Source Administrator (64-bit). On the User DSN tab, click Add.
In the Create New Data Source dialog box, select the driver that you downloaded in Step 1 and click Finish.
In the Microsoft Spark ODBC Driver DSN Setup or Simba Spark ODBC Driver DSN Setup dialog box, configure the parameters.

Parameter
Description
Data Source Name
The name of the data source. You can specify a custom name.
Description
The description of the data source. You can specify a custom description.
Host(s)
The endpoint of the interactive Spark resource group. For more information, see Preparations.
Port
The port of the interactive Spark resource group. The value is fixed at 10000.
Database
The name of the AnalyticDB for MySQL database.
Mechanism
The authentication method. In this topic, User Name and Password is selected.
User Name
The database account of AnalyticDB for MySQL and the name of the interactive Spark resource group. The format is
Resource group name/Database account name.For example, if the resource group name is testjob and the database account name is test, enter
testjob/test.Password
The password of the AnalyticDB for MySQL database account.
Thrift Transport
The connection method. The value is fixed at SASL.
Click SSL Options. In the SSL Options dialog box, clear Enable SSL and click OK.

Click Advanced Options. In the Advanced Options dialog box, select Get Tables with Query.

Click Server Side Properties. Clear Apply properties with queries and click OK.

In the Microsoft Spark ODBC Driver DSN Setup or Simba Spark ODBC Driver DSN Setup dialog box, click Test to test the connection.
A
SUCCESSmessage indicates that the ODBC connection to the AnalyticDB for MySQL interactive Spark resource group is successful.
Open Power BI and click Get data from another source.

In the Get Data dialog box, select ODBC and click Connect.

In the From ODBC dialog box, select the data source that you created in Step 2 and click OK. In this example, the data source is
adb_test.
In the ODBC driver dialog box, click the Windows tab, select Use my current credentials, and then click Connect.

In the Navigator dialog box, select the target data table, preview the data in the pane on the right, and then click Load.
After the configuration is complete, you can start data analytics on this data source. For more information, see the official Power BI documentation.
