By creating a TDSQL for MySQL data source, you can enable Dataphin to read business data from TDSQL for MySQL or write data to TDSQL for MySQL. This topic describes how to create a TDSQL for MySQL data source.
Permission requirements
Only custom global roles with the Create Data Source permission and the super administrator, Data Source Administrator, Division Architect, and project administrator roles can create data sources.
Procedure
On the Dataphin homepage, choose Management Center > Datasource Management from the top navigation bar.
On the Datasource page, click +Create Data Source.
On the Create Data Source page, select TDSQL for MySQL in the Relational Database section.
If you have recently used TDSQL for MySQL, you can also select it in the Recently Used section. You can also enter keywords in the search box to quickly find TDSQL for MySQL.
On the Create TDSQL For MySQL Data Source page, configure the parameters for connecting to the data source.
Configure the basic information of the data source.
Parameter
Description
Datasource Name
Enter a name for the data source. The name must meet the following requirements:
It can contain only Chinese characters, letters, digits, underscores (_), and hyphens (-).
The name can be up to 64 characters in length.
Datasource Code
After you configure the data source code, you can access Dataphin data source tables in Flink_SQL tasks or by using the Dataphin JDBC client in the format of
data source code.table nameordata source code.schema.table namefor quick consumption. If you need to automatically switch data sources based on the task execution environment, access them using the variable format${data source code}.tableor${data source code}.schema.table. For more information, see Dataphin data source table development method.ImportantThe data source code cannot be modified after it is configured successfully.
After the data source code is configured successfully, you can preview data on the object details page in the asset directory and asset inventory.
In Flink SQL, only MySQL, Hologres, MaxCompute, Oracle, StarRocks, Hive, and SelectDB data sources are currently supported.
Data Source Description
Enter a brief description of the TDSQL for MySQL data source. The description cannot exceed 128 characters.
Data Source Configuration
Based on whether the business data source distinguishes between production and development data sources:
If the business data source distinguishes between production and development data sources, select Production + Development Data Source.
If the business data source does not distinguish between production and development data sources, select Production Data Source.
Tag
You can categorize and tag data sources based on tags. For information about how to create tags, see Manage data source tags.
Configure the parameters for connecting the data source to Dataphin.
If you select Production + Development data source for your data source configuration, you need to configure the connection information for the Production + Development data source. If your data source configuration is Production data source, you only need to configure the connection information for the Production data source.
NoteIn most cases, the production data source and development data source should be configured as different data sources to isolate the development environment from the production environment and reduce the impact of the development data source on the production data source. However, Dataphin also supports configuring them as the same data source with identical parameter values.
For Configuration Method, you can select either JDBC URL or Host. The default selection is JDBC URL.
JDBC URL configuration method
Parameter
Description
JDBC URL
The format of the JDBC URL is
jdbc:mysql://host:port/dbname.NoteThe default port for TDSQL for MySQL data sources is 3306.
Username, Password
The Username and Password of the database.
Host configuration method
Host configuration method
Parameter
Description
Server Address
Enter the IP address and port number of the server.
You can click +Add to add multiple sets of IP addresses and port numbers, and click the
icon to delete extra IP addresses and port numbers, but at least one set must be retained.dbname
Enter the database name.
Parameter configuration
Parameter
Description
Parameter
Parameter name: Supports selecting existing parameter names or entering custom parameter names.
Custom parameter names only support uppercase and lowercase English letters, numbers, periods (.), underscores (_), and hyphens (-).
Parameter value: When a parameter name is selected, the parameter value is required. Only supports uppercase and lowercase English letters, numbers, periods (.), underscores (_), and hyphens (-), with a maximum length of 256 characters.
NoteYou can click +Add Parameter to add multiple parameters, and click the
icon to delete extra parameters. You can add up to 30 parameters.Username, Password
The username and password for logging on to the TDSQL for MySQL instance.
NoteWhen the configuration method is set to Host and the data source creation is completed, if you need to switch to the JDBC URL configuration method, the system will concatenate the server's IP address and port number into a JDBC URL for filling.
Configure advanced settings for the data source.
Parameter
Description
connectTimeout
The connectTimeout duration of the database (in milliseconds), default is 900000 milliseconds (15 minutes).
NoteIf you have a connectTimeout configuration in the JDBC URL, the connectTimeout will be the timeout value configured in the JDBC URL.
For data sources created before Dataphin V3.11, the default connectTimeout is
-1, which means no timeout limit.
socketTimeout
The socketTimeout duration of the database (in milliseconds), default is 1800000 milliseconds (30 minutes).
NoteIf you have a socketTimeout configuration in the JDBC URL, the socketTimeout will be the timeout value configured in the JDBC URL.
For data sources created before Dataphin V3.11, the default socketTimeout is
-1, which means no timeout limit.
Connection Retries
When the database connection times out, the system will automatically retry the connection until the set number of retries is completed. If the maximum number of retries is reached and the connection is still unsuccessful, the connection fails.
NoteThe default number of retries is 1, and you can configure a value between 0 and 10.
The connection retry count will be applied by default to offline integration tasks and global quality (requires the asset quality function module to be enabled). In offline integration tasks, you can configure task-level retry counts separately.
NoteRules for duplicate parameter values:
If a parameter exists in JDBC URL, Advanced Settings parameters, and Host Configuration method's parameter configuration, the value in the JDBC URL takes precedence.
If a parameter exists in both JDBC URL and Advanced Settings parameters, the value in the JDBC URL takes precedence.
If a parameter exists in both Advanced Settings parameters and Host Configuration method's parameter configuration, the value in the Advanced Settings parameters takes precedence.
Select a Default Resource Group, which is used to run tasks related to the current data source, including database SQL, offline database migration, data preview, and more.
Perform a Test Connection or directly click OK to save and complete the creation of the TDSQL for MySQL data source.
Click Test Connection, and the system will test whether the data source can connect normally with Dataphin. If you directly click OK, the system will automatically test the connection for all selected clusters. Even if all selected clusters fail to connect, the data source can still be created normally.
Test Connection tests the connection for the Default Cluster or Registered Scheduling Clusters that have been registered in Dataphin and are in normal use. The Default Cluster is selected by default and cannot be deselected. If there are no resource groups under a Registered Scheduling Cluster, connection testing is not supported. You need to create a resource group first before testing the connection.
The selected clusters are only used to test network connectivity with the current data source and are not used for running related tasks later.
The test connection usually takes less than 2 minutes. If it times out, you can click the
icon to view the specific reason and retry.Regardless of whether the test result is Connection Failed, Connection Successful, or Succeeded With Warning, the system will record the generation time of the final result.
NoteOnly the test results for the Default Cluster include three connection statuses: Succeeded With Warning, Connection Successful, and Connection Failed. The test results for Registered Scheduling Clusters in Dataphin only include two connection statuses: Connection Successful and Connection Failed.
When the test result is Connection Failed, you can click the
icon to view the specific failure reason.When the test result is Succeeded With Warning, it means that the application cluster connection is successful but the scheduling cluster connection failed. The current data source cannot be used for data development and integration. You can click the
icon to view the log information.