Offline Data Migration

Last updated: 2020-02-25 17:20:16

PDF

Migrating Data via Console

There are two ways to migrate data through the console: physical backup and logical backup. For more information, please see:

Migrating Data with Command Line Tool

  1. Generate the SQL files to be imported using MySQL command line tool mysqldump, as shown below:
  • The data files exported using mysqldump must be compatible with the SQL specification of your purchased TencentDB for MySQL version. You can log in to the database and get the MySQL version information by running the select version(); Command。 The name of the generated SQL file can contain letters, digits, and underscores but not "test".
  • Make sure that the same database version, mysqldump tool version, and database character set are used. You can specify the character set using the parameter --default-character-set .
  • shell > mysqldump [options] db_name [tbl_name ...] > bak_pathname

    The "options" is the export option. The "db_name" is the database name. The "tbl_name" is the table name, and the "bak_pathname" is the export path.
    For more information on how to export data with mysqldump, see MySQL's official documentation .

    1. Import data to the target database through the MySQL command line tool as follows:
    shell > mysql -h hostname -P port -u username -p < bak_pathname

    Here, "hostname" is the target server for data restoration, "port" is the port of target server, "username" is the username of the database on the target server, and "bak_pathname" is the full path to the backup file.

    Migrate data (Windows system)

    1. Use the mysqldump tool of the Windows system to generate the SQL file to be imported. For details, please refer to Command line tools migrate data The description in.
    2. Go to the command prompt and import the data to the target database through the MySQL command line tool.
    3. Log in to the target MySQL database , execute show databases; Command to see that the backed-up database has been imported to the target database.

    Migrate data (Linux system)

    For more information on how to access a database on a CVM instance, see Accessing a MySQL Database .

    1. Log in to CVM and use the MySQL command line tool mysqldump to generate the SQL file to be imported Take the db_blog database on the cloud database as an example.

    2. Restore the data to the target database through the MySQL command line tool.

    3. Log in to the target MySQL database and execute show databases; Command to see that the backed-up database has been imported to the target database.

    Character Set Encoding Issues of Imported Data Files

    1. If the imported data files do not specify a character set encoding, the one set by the cloud database will be executed.
    2. If the imported data files have specified a character set encoding, the specified one will be executed.
    3. If the character set encoding of imported data files is different from those of the cloud database, it will display unreadable codes.

    For more information, see the character set description in Use Limits .