IMPORT

The IMPORT statement imports the following types of data into CockroachDB:

Tip:

This page has reference information about the IMPORT statement. For instructions and working examples showing how to migrate data from other databases and formats, see the Migration Overview.

Warning:

IMPORT only works for creating new tables. It does not support adding data to existing tables. Also, IMPORT cannot be used within a transaction.

Required privileges

Only members of the admin role can run IMPORT. By default, the root user belongs to the admin role.

Synopsis

Import a table from CSV

IMPORTTABLEtable_nameCREATEUSINGfile_location(table_elem_list)CSVDATA(file_location,)WITHkv_option_list

Import a database or table from dump file

IMPORTTABLEtable_nameFROMimport_formatfile_locationWITHkv_option_list

Parameters

For import from CSV

ParameterDescription
table_nameThe name of the table you want to import/create.
table_elem_listThe table schema you want to use.
CREATE USING file_locationIf not specifying the table schema inline via table_elem_list, this is the URL of a CSV file containing the table schema.
file_locationThe URL of a CSV file containing the table data. This can be a comma-separated list of URLs to CSV files. For an example, see Import a table from multiple CSV files below.
WITH kv_option_listControl your import's behavior with these options.

For import from dump file

ParameterDescription
table_nameThe name of the table you want to import/create. Use this when the dump file contains a specific table. Leave out TABLE table_name FROM when the dump file contains an entire database.
import_formatPGDUMP or MYSQLDUMP
file_locationThe URL of a dump file you want to import.
WITH kv_option_listControl your import's behavior with these options.

Import file URLs

URLs for the files you want to import must use the format shown below. For examples, see Example file URLs.

  1. [scheme]://[host]/[path]?[parameters]
LocationSchemeHostParameters
Amazon S3s3Bucket nameAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
AzureazureN/A (see Example file URLsAZURE_ACCOUNT_KEY, AZURE_ACCOUNT_NAME
Google Cloud 1gsBucket nameAUTH (optional; can be default, implicit, or specified), CREDENTIALS
HTTP 2httpRemote hostN/A
NFS/Local 3nodelocalEmpty or nodeID 4 (see Example file URLs)N/A
S3-compatible services 5s3Bucket nameAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, AWS_REGION 6 (optional), AWS_ENDPOINT

Note:

The location parameters often contain special characters that need to be URI-encoded. Use Javascript's encodeURIComponent function or Go language's url.QueryEscape function to URI-encode the parameters. Other languages provide similar functions to URI-encode special characters.

Note:

If your environment requires an HTTP or HTTPS proxy server for outgoing connections, you can set the standard HTTP_PROXY and HTTPS_PROXY environment variables when starting CockroachDB.

  • 1If the AUTH parameter is not specified, the cloudstorage.gs.default.key cluster setting will be used if it is non-empty, otherwise the implicit behavior is used. If the AUTH parameter is implicit, all GCS connections use Google's default authentication strategy. If the AUTH parameter is default, the cloudstorage.gs.default.key cluster setting must be set to the contents of a service account file which will be used during authentication. New in v19.1: If the AUTH parameter is specified, GCS connections are authenticated on a per-statement basis, which allows the JSON key object to be sent in the CREDENTIALS parameter. The JSON key object should be base64-encoded (using the standard encoding in RFC 4648).

  • 2 You can create your own HTTP server with Caddy or nginx. A custom root CA can be appended to the system's default CAs by setting the cloudstorage.http.custom_ca cluster setting, which will be used when verifying certificates from HTTPS URLs.

  • 3 The file system backup location on the NFS drive is relative to the path specified by the —external-io-dir flag set while starting the node. If the flag is set to disabled, then imports from local directories and NFS drives are disabled.

  • 4New in v19.1: The host component of NFS/Local can either be empty or the nodeID. If the nodeID is specified, it is currently ignored (i.e., any node can be sent work and it will look in its local input/output directory); however, the nodeID will likely be required in the future.

  • 5 A custom root CA can be appended to the system's default CAs by setting the cloudstorage.http.custom_ca cluster setting, which will be used when verifying certificates from an S3-compatible service.

  • 6 The AWS_REGION parameter is optional since it is not a required parameter for most S3-compatible services. Specify the parameter only if your S3-compatible service requires it.

Example file URLs

LocationExample
Amazon S3s3://acme-co/employees.sql?AWS_ACCESS_KEY_ID=123&AWS_SECRET_ACCESS_KEY=456
Azureazure://employees.sql?AZURE_ACCOUNT_KEY=123&AZURE_ACCOUNT_NAME=acme-co
Google Cloudgs://acme-co/employees.sql
HTTPhttp://localhost:8080/employees.sql
NFS/Localnodelocal:///employees.sql, nodelocal://2/employees.sql

Import options

You can control the IMPORT process's behavior using any of the following key-value pairs as a kv_option.

KeyContextValueRequired?Example
delimiterCSVThe unicode character that delimits columns in your rows. Default: ,.NoTo use tab-delimited values: IMPORT TABLE foo (..) CSV DATA ('file.csv') WITH delimiter = e'\t'
commentCSVThe unicode character that identifies rows to skip.NoIMPORT TABLE foo (..) CSV DATA ('file.csv') WITH comment = '#'
nullifCSVThe string that should be converted to NULL.NoTo use empty columns as NULL: IMPORT TABLE foo (..) CSV DATA ('file.csv') WITH nullif = ''
skipCSVThe number of rows to be skipped while importing a file. Default: '0'.NoTo import CSV files with column headers: IMPORT … CSV DATA ('file.csv') WITH skip = '1'
decompressGeneralThe decompression codec to be used: gzip, bzip, auto, or none. Default: 'auto', which guesses based on file extension (.gz, .bz, .bz2). none disables decompression.NoIMPORT … WITH decompress = 'bzip'
skip_foreign_keysPostgres, MySQLIgnore foreign key constraints in the dump file's DDL. Off by default. May be necessary to import a table with unsatisfied foreign key constraints from a full database dump.NoIMPORT TABLE foo FROM MYSQLDUMP 'dump.sql' WITH skip_foreign_keys
max_row_sizePostgresOverride limit on line size. Default: 0.5MB. This setting may need to be tweaked if your Postgres dump file has extremely long lines, for example as part of a COPY statement.NoIMPORT PGDUMP DATA … WITH max_row_size = '5MB'

For examples showing how to use these options, see the Examples section below.

For instructions and working examples showing how to migrate data from other databases and formats, see the Migration Overview.

Requirements

Prerequisites

Before using IMPORT, you should have:

  • The schema of the table you want to import.
  • The data you want to import, preferably hosted on cloud storage. This location must be equally accessible to all nodes using the same import file location. This is necessary because the IMPORT statement is issued once by the client, but is executed concurrently across all nodes of the cluster. For more information, see the Import file location section below.

Import targets

Imported tables must not exist and must be created in the IMPORT statement. If the table you want to import already exists, you must drop it with DROP TABLE.

You can specify the target database in the table name in the IMPORT statement. If it's not specified there, the active database in the SQL session is used.

Create table

Your IMPORT statement must reference a CREATE TABLE statement representing the schema of the data you want to import. You have several options:

We also recommend specifying all secondary indexes you want to use in the CREATE TABLE statement. It is possible to add secondary indexes later, but it is significantly faster to specify them during import.

Note:

By default, the Postgres and MySQL import formats support foreign keys. However, the most common dependency issues during import are caused by unsatisfied foreign key relationships that cause errors like pq: there is no unique constraint matching given keys for referenced table tablename. You can avoid these issues by adding the skip_foreign_keys option to your IMPORT statement as needed. Ignoring foreign constraints will also speed up data import.

Available storage

Each node in the cluster is assigned an equal part of the imported data, and so must have enough temp space to store it. In addition, data is persisted as a normal table, and so there must also be enough space to hold the final, replicated data. The node's first-listed/default store directory must have enough available storage to hold its portion of the data.

On cockroach start, if you set —max-disk-temp-storage, it must also be greater than the portion of the data a node will store in temp space.

Import file location

We strongly recommend using cloud/remote storage (Amazon S3, Google Cloud Platform, etc.) for the data you want to import.

Local files are supported; however, they must be accessible to all nodes in the cluster using identical Import file URLs.

To import a local file, you have the following options:

  • Option 1. Run a local file server to make the file accessible from all nodes.

  • Option 2. Make the file accessible from each local node's store:

    • Create an extern directory on each node's store. The pathname will differ depending on the —store flag passed to cockroach start (if any), but will look something like /path/to/cockroach-data/extern/.
    • Copy the file to each node's extern directory.
    • Assuming the file is called data.sql, you can access it in your IMPORT statement using the following import file URL: 'nodelocal:///data.sql'.

Table users and privileges

Imported tables are treated as new tables, so you must GRANT privileges to them.

Performance

All nodes are used during the import job, which means all nodes' CPU and RAM will be partially consumed by the IMPORT task in addition to serving normal traffic.

Viewing and controlling import jobs

After CockroachDB successfully initiates an import, it registers the import as a job, which you can view with SHOW JOBS.

After the import has been initiated, you can control it with PAUSE JOB, RESUME JOB, and CANCEL JOB.

Warning:
Pausing and then resuming an IMPORT job will cause it to restart from the beginning.

Examples

Import a table from a CSV file

To manually specify the table schema:

Amazon S3:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('s3://acme-co/customers.csv?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]&AWS_SESSION_TOKEN=[placeholder]')
  7. ;

Azure:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('azure://acme-co/customer-import-data.csv?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co')
  7. ;

Google Cloud:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('gs://acme-co/customers.csv')
  7. ;

To use a file to specify the table schema:

Amazon S3:

  1. > IMPORT TABLE customers
  2. CREATE USING 's3://acme-co/customers-create-table.sql?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]'
  3. CSV DATA ('s3://acme-co/customers.csv?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]')
  4. ;

Azure:

  1. > IMPORT TABLE customers
  2. CREATE USING 'azure://acme-co/customer-create-table.sql?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co'
  3. CSV DATA ('azure://acme-co/customer-import-data.csv?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co')
  4. ;

Google Cloud:

  1. > IMPORT TABLE customers
  2. CREATE USING 'gs://acme-co/customers-create-table.sql'
  3. CSV DATA ('gs://acme-co/customers.csv')
  4. ;

Import a table from multiple CSV files

Amazon S3:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA (
  7. 's3://acme-co/customers.csv?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]',
  8. 's3://acme-co/customers2.csv?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder',
  9. 's3://acme-co/customers3.csv?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]',
  10. 's3://acme-co/customers4.csv?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]',
  11. );

Azure:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA (
  7. 'azure://acme-co/customer-import-data1.1.csv?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co',
  8. 'azure://acme-co/customer-import-data1.2.csv?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co',
  9. 'azure://acme-co/customer-import-data1.3.csv?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co',
  10. 'azure://acme-co/customer-import-data1.4.csv?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co',
  11. 'azure://acme-co/customer-import-data1.5.csv?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co',
  12. );

Google Cloud:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA (
  7. 'gs://acme-co/customers.csv',
  8. 'gs://acme-co/customers2.csv',
  9. 'gs://acme-co/customers3.csv',
  10. 'gs://acme-co/customers4.csv',
  11. );

Import a table from a TSV file

Amazon S3:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('s3://acme-co/customers.tsv?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]')
  7. WITH
  8. delimiter = e'\t'
  9. ;

Azure:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('azure://acme-co/customer-import-data.tsv?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co')
  7. WITH
  8. delimiter = e'\t'
  9. ;

Google Cloud:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('gs://acme-co/customers.tsv')
  7. WITH
  8. delimiter = e'\t'
  9. ;

Skip commented lines

The comment option determines which Unicode character marks the rows in the data to be skipped.

Amazon S3:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('s3://acme-co/customers.csv?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]')
  7. WITH
  8. comment = '#'
  9. ;

Azure:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('azure://acme-co/customer-import-data.csv?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co')
  7. WITH
  8. comment = '#'
  9. ;

Google Cloud:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('gs://acme-co/customers.csv')
  7. WITH
  8. comment = '#'
  9. ;

Skip first n lines

The skip option determines the number of header rows to skip when importing a file.

Amazon S3:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('s3://acme-co/customers.csv?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]')
  7. WITH
  8. skip = '2'
  9. ;

Azure:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('azure://acme-co/customer-import-data.csv?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co')
  7. WITH
  8. skip = '2'
  9. ;

Google Cloud:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('gs://acme-co/customers.csv')
  7. WITH
  8. skip = '2'
  9. ;

Use blank characters as NULL

The nullif option defines which string should be converted to NULL.

Amazon S3:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('s3://acme-co/employees.csv?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]')
  7. WITH
  8. nullif = ''
  9. ;

Azure:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('azure://acme-co/customer-import-data.csv?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co')
  7. WITH
  8. nullif = ''
  9. ;

Google Cloud:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('gs://acme-co/customers.csv')
  7. WITH
  8. nullif = ''
  9. ;

Import a compressed CSV file

CockroachDB chooses the decompression codec based on the filename (the common extensions .gz or .bz2 and .bz) and uses the codec to decompress the file during import.

Amazon S3:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('s3://acme-co/employees.csv.gz?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]')
  7. ;

Azure:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('azure://acme-co/customer-import-data.csv.gz?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co')
  7. ;

Google Cloud:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('gs://acme-co/customers.csv.gz')
  7. ;

Optionally, you can use the decompress option to specify the codec to be used for decompressing the file during import:

Amazon S3:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('s3://acme-co/employees.csv.gz?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]')
  7. WITH
  8. decompress = 'gzip'
  9. ;

Azure:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('azure://acme-co/customer-import-data.csv.gz.latest?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co')
  7. WITH
  8. decompress = 'gzip'
  9. ;

Google Cloud:

  1. > IMPORT TABLE customers (
  2. id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  3. name TEXT,
  4. INDEX name_idx (name)
  5. )
  6. CSV DATA ('gs://acme-co/customers.csv.gz')
  7. WITH
  8. decompress = 'gzip'
  9. ;

Import a Postgres database dump

Amazon S3:

  1. > IMPORT PGDUMP 's3://your-external-storage/employees.sql?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]';

Azure:

  1. > IMPORT PGDUMP 'azure://acme-co/employees.sql?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co';

Google Cloud:

  1. > IMPORT PGDUMP 'gs://acme-co/employees.sql';

For the commands above to succeed, you need to have created the dump file with specific flags to pg_dump. For more information, see Migrate from Postgres.

Import a table from a Postgres database dump

Amazon S3:

  1. > IMPORT TABLE employees FROM PGDUMP 's3://your-external-storage/employees-full.sql?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]' WITH skip_foreign_keys;

Azure:

  1. > IMPORT TABLE employees FROM PGDUMP 'azure://acme-co/employees.sql?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co' WITH skip_foreign_keys;

Google Cloud:

  1. > IMPORT TABLE employees FROM PGDUMP 'gs://acme-co/employees.sql' WITH skip_foreign_keys;

If the table schema specifies foreign keys into tables that do not exist yet, the WITH skip_foreign_keys shown may be needed. For more information, see the list of import options.

For the command above to succeed, you need to have created the dump file with specific flags to pg_dump. For more information, see Migrate from Postgres.

Import a CockroachDB dump file

Cockroach dump files can be imported using the IMPORT PGDUMP.

Amazon S3:

  1. > IMPORT PGDUMP 's3://your-external-storage/employees-full.sql?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]';

Azure:

  1. > IMPORT PGDUMP 'azure://acme-co/employees.sql?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co';

Google Cloud:

  1. > IMPORT PGDUMP 'gs://acme-co/employees.sql';

For more information, see SQL Dump (Export).

Import a MySQL database dump

Amazon S3:

  1. > IMPORT MYSQLDUMP 's3://your-external-storage/employees-full.sql?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]';

Azure:

  1. > IMPORT MYSQLDUMP 'azure://acme-co/employees.sql?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co';

Google Cloud:

  1. > IMPORT MYSQLDUMP 'gs://acme-co/employees.sql';

For more detailed information about importing data from MySQL, see Migrate from MySQL.

Import a table from a MySQL database dump

Amazon S3:

  1. > IMPORT TABLE employees FROM MYSQLDUMP 's3://your-external-storage/employees-full.sql?AWS_ACCESS_KEY_ID=[placeholder]&AWS_SECRET_ACCESS_KEY=[placeholder]' WITH skip_foreign_keys

Azure:

  1. > IMPORT TABLE employees FROM MYSQLDUMP 'azure://acme-co/employees.sql?AZURE_ACCOUNT_KEY=hash&AZURE_ACCOUNT_NAME=acme-co' WITH skip_foreign_keys

Google Cloud:

  1. > IMPORT TABLE employees FROM MYSQLDUMP 'gs://acme-co/employees.sql' WITH skip_foreign_keys

If the table schema specifies foreign keys into tables that do not exist yet, the WITH skip_foreign_keys shown may be needed. For more information, see the list of import options.

For more detailed information about importing data from MySQL, see Migrate from MySQL.

Known limitation

IMPORT can sometimes fail with a "context canceled" error, or can restart itself many times without ever finishing. If this is happening, it is likely due to a high amount of disk contention. This can be mitigated by setting the kv.bulk_io_write.max_rate cluster setting to a value below your max disk write speed. For example, to set it to 10MB/s, execute:

  1. > SET CLUSTER SETTING kv.bulk_io_write.max_rate = '10MB';

See also

Was this page helpful?
YesNo