All pages
Powered by GitBook
1 of 3

Data Import with MariaDB Enterprise Server

LOAD DATA With LOAD DATA LOCAL INFILE

Overview

MariaDB Enterprise Server users can import data into a database using the LOAD DATA LOCAL INFILE statement:

  • The LOAD DATA LOCAL INFILE statement can import data from TSV and CSV files

  • The LOAD DATA LOCAL INFILE statement can be executed by any client or connector

Compatibility

Import Schema

  1. Determine the connection parameters for your MariaDB Enterprise Server database.

  2. Use mariadb client with the connection information to import your schema into your MariaDB Enterprise Server database:

$ mariadb --host FULLY_QUALIFIED_DOMAIN_NAME --port TCP_PORT \
      --user DATABASE_USER --password \
      --ssl-verify-server-cert \
      --ssl-ca ~/PATH_TO_PEM_FILE \
      --default-character-set=utf8 \
      < mariadb_schema.sql
  • Replace FULLY_QUALIFIED_DOMAIN_NAME with the IP address or Fully Qualified Domain Name of your database

  • Replace TCP_PORT with the TCP port of your database

  • Replace DATABASE_USER with the username for your database user account

  • If TLS is required, replace /PATH_TO_PEM_FILE with the path to the certificate authority chain (.pem) file

  1. After the command is executed, you will be prompted for the password of your database user account.

Import Data

  1. Determine the connection parameters for your MariaDB Enterprise Server database.

  2. Connect with the mariadb client and specify the --local-infile option, which is needed by the next step:

$ mariadb --host FULLY_QUALIFIED_DOMAIN_NAME --port TCP_PORT \
      --user DATABASE_USER --password \
      --ssl-verify-server-cert \
      --ssl-ca ~/PATH_TO_PEM_FILE \
      --default-character-set=utf8 \
      --local-infile

Replace FULLY_QUALIFIED_DOMAIN_NAME with the IP address or Fully Qualified Domain Name of your database

Replace TCP_PORT with the TCP port of your database

Replace DATABASE_USER with the username for your database user account

If TLS is required, replace /PATH_TO_PEM_FILE with the path to the certificate authority chain (.pem) file

  1. After the command is executed, you will be prompted for the password of your database user account.

  2. For each table that you want to import, execute the LOAD DATA LOCAL INFILE statement to import the data from the TSV or CSV file into your MariaDB Enterprise Server database.

For a TSV file:

LOAD DATA LOCAL INFILE 'contacts.tsv'
INTO TABLE accounts.contacts;
For a CSV file:
LOAD DATA LOCAL INFILE 'contacts.csv'
INTO TABLE accounts.contacts
FIELDS TERMINATED BY ',';

MariaDB Connectors

To execute the LOAD DATA LOCAL INFILE statement, most clients and connectors require a specific option to be enabled.

The section above mentions that mariadb client requires the --local-infile option to be specified.

If you are using a MariaDB Connector instead of the mariadb client, then you must use a different method to enable support for the LOAD DATA LOCAL INFILE statement.

If you are using MariaDB Connector/C, the MYSQL_OPT_LOCAL_INFILE option can be set with the mysql_optionsv() function:

/* enable local infile */
unsigned int enable_local_infile = 1;
mysql_optionsv(mysql, MYSQL_OPT_LOCAL_INFILE, (void *) &enable_local_infile);

If you are using MariaDB Connector/J, the allowLocalInfile parameter can be set for the connection:

Connection connection = DriverManager.getConnection("jdbc:mariadb://FULLY_QUALIFIED_DOMAIN_NAME:TCP_PORT/test?user=DATABASE_USER&password=DATABASE_PASSWORD&allowLocalInfile=true");

If you are using MariaDB Connector/Node.js, the permitLocalInfile parameter can be set for the connection:

mariadb.createConnection({
   host: 'FULLY_QUALIFIED_DOMAIN_NAME',
   port: 'TCP_PORT',
   user:'DATABASE_USER',
   password: 'DATABASE_PASSWORD',
   permitLocalInfile: 'true'
 });

If you are using MariaDB Connector/Python, the local_infile parameter can be set for the connection:

conn = mariadb.connect(
   user="DATABASE_USER",
   password="DATABASE_PASSWORD",
   host="FULLY_QUALIFIED_DOMAIN_NAME",
   port=TCP_PORT,
   local_infile=true)

This page is: Copyright © 2025 MariaDB. All rights reserved.

mariadb-import-utility

Mariadb Import Utility

Overview

MariaDB Enterprise Server users can import data into a database 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 files

  • The mariadb-import utility is available for Linux and Windows

  • The mariadb-import utility supports many command-line options

Compatibility

Installation

Installation of MariaDB Import varies by operating system.

Linux (Repository)

  1. Configure a MariaDB repository.

Before MariaDB Import can be installed on Linux, a MariaDB repository must be configured. MariaDB Corporation offers multiple repositories: **For MariaDB Corporation customers, the MariaDB Enterprise Repository is available.**For anyone else, the MariaDB Community Repository is publicly available.

For additional information on how to configure a MariaDB repository, see "Configure MariaDB Repository".

  1. Install MariaDB Import and package dependencies.

Install on CentOS / RHEL / Rocky Linux (YUM):

$ sudo yum install MariaDB-client

Install on Debian / Ubuntu (APT):

$ sudo apt install mariadb-client

Install on SLES (ZYpp):

$ sudo zypper install MariaDB-client

Windows

  1. Access MariaDB Downloads for MariaDB Community Server.

  2. In the "Version" dropdown, select the version you want to download.

  3. In the "OS" dropdown, select "MS Windows (64-bit)".

  4. Click the "Download" button to download the MSI package.

  5. When the MSI package finishes downloading, run it.

  6. On the first screen, click "Next" to start the Setup Wizard.

  7. On the second screen, click the license agreement checkbox, and then click "Next".

  8. 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".

  1. On the next screen, click "Install".

  2. When the installation process completes, click "Finish".

Import Data

The procedure to import data depends on the operating system.

Linux

  1. Determine the connection parameters for your MariaDB Enterprise Server database.

  2. Use MariaDB Import with the connection information to import the data from the TSV or CSV file into your MariaDB Enterprise Server database:

$ 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 IP address or Fully Qualified Domain Name of your database Replace TCP_PORT with the TCP port of your databaseReplace DATABASE_USER with the username for your database user account If TLS is required, replace /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)

  1. After the command is executed, you will be prompted for the password of your database user account.

Windows

  1. 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%"
  1. Determine the connection parameters for your MariaDB Enterprise Server database.

  2. Use MariaDB Import with the connection information to import the data from the TSV or CSV file into your MariaDB Enterprise Server database:

$ 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 IP address or Fully Qualified Domain Name of your database Replace TCP_PORT with the TCP port of your databaseReplace DATABASE_USER with the username for your database user account Replace /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)

  1. After the command is executed, you will be prompted for the password of your database user account.

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.

This page is: Copyright © 2025 MariaDB. All rights reserved.