- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we transfer information between MySQL and data files through command line?
Transferring the information between MySQL and data files mean importing data from data files into our database or exporting data from our database into files. MySQL is having two commands that can be used to import or export data between MySQL and data files through the command line −
Actually, mysqlimport command reads a spread of data formats, including comma-and tab-delimited, and inserts the information into a database. In other words, we can say that it provides a command-line interface for importing the data i.e. command-line interface to the LOAD DATA INFILE statement. Its syntax would be as follows −
Mysqlimport [options] database_name filename1 filename2 …
Here, filenames must correspond to the tables into which data will be imported.
Basically, mysqldump is a client program that can be used to dump a database or a collection of databases for backup or transfer to another database server. It can export tables as tab-delimited data files or produce SQL-format dump files that contain CREATE TABLE and INSERT statements for re-creating the dumped files. Its syntax would be as follows −
Mysqldump –tab=dir_name options db_name tbl_name …
As we are specifying –tab=dir_name means mysqldump export the tables as tab-delimited data files and issue SELECT … INTO OUTFILE statement to tell MySQL server to write each dumped table as a tab-delimited text file in the dir_name directory.
Both the above-described commands are similar in the sense that they are related to the transfer of data either from the data file to database or from the database to the data file.
- Related Articles
- How can we transfer information between MySQL and data files?
- How can we return to windows command shell from MySQL command line tool?
- How can we analyze the tables of a particular database from MySQL Server command line?
- How to swap two files in Linux command line?
- What is MySQL CREATE command? How can we create both database and table with this command?
- How can we get the list of tables in a particular database from MySQL Server command line?
- What are some frequently used mysqlimport options while uploading the data into MySQL table through command line?
- How can we access tables through MySQL stored procedures?
- How to find the MySQL data directory from command line in Windows?
- How can we establish MySQL database by using MySQL binary at command\nprompt?
- How can we use WHERE clause with MySQL INSERT INTO command?
- In MySQL, how we can write Multiple-line statement?
- How to see spaces in data when selecting with MySQL command line client?
- Transfer Files Between Linux Machines Over SSH
- How can we import CSV files into MySQL tables by using mysqlimport?