Technology Encyclopedia Home >How to import data using TDSQL-C for MySQL?

How to import data using TDSQL-C for MySQL?

To import data into TDSQL-C for MySQL, you can use several methods. One common approach is using the mysql command-line client or a GUI tool like MySQL Workbench.

Using the mysql Command-Line Client:

  1. Export Data from Source Database: First, export the data from your source database to a file, typically in SQL format using mysqldump.

    mysqldump -u username -p database_name > backup.sql
    
  2. Import Data to TDSQL-C for MySQL: Then, import this SQL file into your TDSQL-C for MySQL instance.

    mysql -h host_address -P port -u username -p database_name < backup.sql
    

    Replace host_address, port, username, and database_name with your TDSQL-C for MySQL instance details.

Using MySQL Workbench:

  1. Open MySQL Workbench and connect to your TDSQL-C for MySQL instance.
  2. Go to Server > Data Import.
  3. Choose the export file (e.g., backup.sql) and select the target schema.
  4. Follow the prompts to complete the import process.

Example:

Suppose you have a database named testdb on a local MySQL server, and you want to import it into TDSQL-C for MySQL.

  1. Export:

    mysqldump -u root -p testdb > testdb_backup.sql
    
  2. Import:

    mysql -h your_tdsql_c_host -P your_port -u your_username -p testdb < testdb_backup.sql
    

Replace your_tdsql_c_host, your_port, and your_username with your actual TDSQL-C for MySQL credentials.

For large-scale data imports or more complex migration scenarios, consider using Tencent Cloud's Data Transmission Service (DTS), which provides a more efficient and reliable way to migrate databases.