Exporting a MySQL Instance
Export a MySQL instance to an Object Storage bucket using dump utilities of MySQL Shell. You can then use the data import feature to import data from the Object Storage bucket to a DB system present in the same region.
Use either of the following dump utility:
util.dumpInstance(outputUrl[, options])
: MySQL instance export utility that exports all compatible schemas to an Object Storage bucket or to local files. By default, this utility exports users, events, routines, and triggers. See Dump Utilities.util.dumpSchemas(schemas, outputUrl[, options])
: MySQL schema export utility that exports selected schemas to an Object Storage bucket or to local files.util.dumpTables(schema, tables, outputUrl[, options])
: MySQL table export utility that exports selected tables of a schema to an Object Storage bucket or to local files.
While exporting data, perform compatibility checks on the schemas. If there are any issues, the dump utility aborts the export and produces a detailed list of issues and suggests steps to correct them. Also, if there is a connection interruption while exporting data, you have to re-run the dump utility. You cannot pause and resume exporting data.
Using MySQL Shell
Use the MySQL Shell
dumpInstance
utility to export a MySQL instance to an Object Storage
bucket.
- MySQL Shell 8.0.27, or higher. Exports created by MySQL Shell 8.0.27, or higher, cannot be imported by earlier versions of MySQL Shell. The latest version of MySQL Shell is recommended.
- Access to Object Storage and an existing bucket.
- A valid configuration file. If you have installed and configured the CLI in the default location, you have a valid configuration file. If you have not installed and configured the CLI, you must either install it, or create a configuration file manually. See SDK and CLI Configuration File.
Compatibility Checks
HeatWave Service has several security-related restrictions that are not present in a MySQL instance. Use the ocimds
option of the dump utility to perform compatibility checks on the dumped data, and if there are any issues, the utility aborts the dump and produces a detailed list of issues and suggests steps to correct them.
The following command shows how to perform compatibility checks using the ocimds
option in the dryrun
mode. Some issues found by the ocimds
option may require you to manually edit the schema before it can be loaded into HeatWave Service.
util.dumpInstance("", {mode: "dryrun", ocimds: true})
After you have identified the compatibility issues and compatibility options, you can specify the options in the command that exports the data.
util.dumpInstance("<BucketPrefix>", {osBucketName: "<MDSBucket>", ocimds: true,
compatibility: ["force_innodb", "strip_definers", "strip_restricted_grants",
"skip_invalid_accounts", "strip_tablespaces", "ignore_missing_pks"] } )
You can use the following comma-separated compatibility options to automatically modify the exported data, which resolves some of these compatibility issues:
force_innodb
: HeatWave Service supports the InnoDB storage engine only. This option modifies theENGINE
clause ofCREATE TABLE
statements that use incompatible storage engines and replaces them with InnoDB.strip_definers
: Strips the"DEFINER=account"
clause from views, routines, events, and triggers. HeatWave Service requires special privileges to create these objects with a definer other than the user loading the schema. By stripping theDEFINER
clause, these objects will be created with that default definer. Views and Routines have theirSQL SECURITY
clause changed fromDEFINER
toINVOKER
. This ensures that the access permissions of the account querying or calling these are applied, instead of the user that created them. If your database security model requires views and routines have more privileges than their invoker, manually modify the schema before loading it. See DEFINER and SQL Security.strip_restricted_grants
: Certain privileges are restricted in the HeatWave Service. Privileges such asRELOAD
,FILE
,SUPER
,BINLOG_ADMIN
, andSET_USER_ID
. You cannot create users granting these privileges. This option strips these privileges from dumpedGRANT
statements.skip_invalid_accounts
: You cannot export a user that has no password defined. This option skips any such users.strip_tablespaces
: HeatWave Service has some restrictions on tablespaces. This option strips theTABLESPACE
option fromCREATE TABLE
statements, so all tables are created in their default tablespaces.- Primary key flags:
create_invisible_pks
: Primary keys are required by high availability DB systems. If you intend to export data for use in a highly available DB system, add primary keys if they are not defined on the tables. This compatibility flag adds invisible primary keys to each table which requires them. See Prerequisites.ignore_missing_pks
: If you do not intend to import into a high availability DB system, this compatibility flag ignores missing primary keys in your dump.
Additionally, DATA DIRECTORY
, INDEX
DIRECTORY
, and ENCRYPTION
options in CREATE
TABLE
statements are always commented out in DDL scripts if the
ocimds
option is enabled.
If you intend to export an older version of MySQL, such as 5.7.9, and if you are using a MySQL Shell version older than 8.0.30, it is recommended to run the MySQL Shell Upgrade Checker Utility to generate a report of all potential issues with your migration. See Upgrade Checker Utility.
Related Topics