Import Data with mariadb-import
This page is part of MariaDB's Documentation.
The parent of this page is: Data Import / Load
Topics on this page:
Overview
MariaDB SkySQL customers can import data into a SkySQL service using the mariadb-import
utility:
The
mariadb-import
utility provides a command-line interface (CLI)The
mariadb-import
utility can import data from TSV and CSV filesThe
mariadb-import
utility is available for Linux and WindowsThe
mariadb-import
utility supports many command-line options
Compatibility
Distributed Transactions
Multi-Node Analytics
Replicated Transactions
Single Node Analytics
Single Node Transactions
Installation
Installation of MariaDB Import varies by operating system.
CentOS / RHEL
Configure YUM package repositories:
$ sudo yum install curl $ curl -LsSO https://downloads.mariadb.com/MariaDB/mariadb_repo_setup $ echo "6083ef1974d11f49d42ae668fb9d513f7dc2c6276ffa47caed488c4b47268593 mariadb_repo_setup" \ | sha256sum -c - $ chmod +x mariadb_repo_setup $ sudo ./mariadb_repo_setup \ --mariadb-server-version="mariadb-10.6"
Install MariaDB Import and package dependencies:
$ sudo yum install MariaDB-client
Debian / Ubuntu
Configure APT package repositories:
$ sudo apt install curl $ curl -LsSO https://downloads.mariadb.com/MariaDB/mariadb_repo_setup $ echo "6083ef1974d11f49d42ae668fb9d513f7dc2c6276ffa47caed488c4b47268593 mariadb_repo_setup" \ | sha256sum -c - $ chmod +x mariadb_repo_setup $ sudo ./mariadb_repo_setup \ --mariadb-server-version="mariadb-10.6" $ sudo apt update
Install MariaDB Import and package dependencies:
$ sudo apt install mariadb-client
SLES
Configure ZYpp package repositories:
$ sudo zypper install curl $ curl -LsSO https://downloads.mariadb.com/MariaDB/mariadb_repo_setup $ echo "6083ef1974d11f49d42ae668fb9d513f7dc2c6276ffa47caed488c4b47268593 mariadb_repo_setup" \ | sha256sum -c - $ chmod +x mariadb_repo_setup $ sudo ./mariadb_repo_setup \ --mariadb-server-version="mariadb-10.6"
Install MariaDB Import and package dependencies:
$ sudo zypper install MariaDB-client
Windows
Access MariaDB Downloads for MariaDB Community Server.
In the "Version" dropdown, select the version you want to download.
In the "OS" dropdown, select "MS Windows (64-bit)".
Click the "Download" button to download the MSI package.
When the MSI package finishes downloading, run it.
On the first screen, click "Next" to start the Setup Wizard.
On the second screen, click the license agreement checkbox, and then click "Next".
On the third screen, select the components you want to install. If you only want the standard MariaDB Client tools:
Deselect "Database instance".
Deselect "Backup utilities".
Deselect "Development Components".
Deselect "Third party tools".
When only "Client programs" is selected, click "Next".
On the next screen, click "Install".
When the installation process completes, click "Finish".
Import Data
The procedure to import data depends on the operating system.
Linux
Determine the connection parameters for your MariaDB SkySQL service.
Use MariaDB Import with the connection information to import the data from the TSV or CSV file into your MariaDB SkySQL database service:
$ mariadb-import --host FULLY_QUALIFIED_DOMAIN_NAME --port TCP_PORT \ --user DATABASE_USER --password \ --ssl-verify-server-cert \ --ssl-ca ~/PATH_TO_PEM_FILE \ --local \ --ignore-lines=1 \ accounts contacts.tsv
Replace
FULLY_QUALIFIED_DOMAIN_NAME
with the Fully Qualified Domain Name of your serviceReplace
TCP_PORT
with the read-write or read-only port of your serviceReplace
DATABASE_USER
with the default username for your service, or the username you createdReplace
~/PATH_TO_PEM_FILE
with the path to the certificate authority chain (.pem) fileIf your file is a CSV file, rather than a TSV file, specify
--fields-terminated-by=,
Specify the database name as the first argument (from above,
accounts
)The table name is extracted from the TSV or CSV file's basename (from above,
contacts
)
After the command is executed, you will be prompted for a password. Enter the default password for your default user, the password you set for the default user, or the password for the database user you created.
Windows
Fix your executable search path.
On Windows, MariaDB Import is not typically found in the executable search path by default. You must find its installation path, and add that path to the executable search path:
$ SET "PATH=C:\Program Files\MariaDB 10.6\bin;%PATH%"
Determine the connection parameters for your MariaDB SkySQL service.
Use MariaDB Import with the connection information to import the data from the TSV or CSV file into your MariaDB SkySQL database service:
$ mariadb-import --host FULLY_QUALIFIED_DOMAIN_NAME --port TCP_PORT \ --user DATABASE_USER --password \ --ssl-verify-server-cert \ --ssl-ca ~/PATH_TO_PEM_FILE \ --local \ --ignore-lines=1 \ accounts contacts.tsv
Replace
FULLY_QUALIFIED_DOMAIN_NAME
with the Fully Qualified Domain Name of your serviceReplace
TCP_PORT
with the read-write or read-only port of your serviceReplace
DATABASE_USER
with the default username for your service, or the username you createdReplace
~/PATH_TO_PEM_FILE
with the path to the certificate authority chain (.pem) fileIf your file is a CSV file, rather than a TSV file, specify
--fields-terminated-by=,
Specify the database name as the first argument (from above,
accounts
)The table name is extracted from the TSV or CSV file's basename (from above,
contacts
)
After the command is executed, you will be prompted for a password. Enter the default password for your default user, the password you set for the default user, or the password for the database user you created.
MariaDB Import 10.3 and Older
The instructions provided above are written for MariaDB Import 10.4 and later, which uses the binary filename of mariadb-import
.
For MariaDB Import 10.3 and older, the binary filename was mysqlimport
. The instructions can be adapted for MariaDB Import 10.3 and older by executing mysqlimport
rather than mariadb-import
.