Database Reference
In-Depth Information
Restoring and importing data with mysqlimport
We talked briefly about mysqlimport in the previous section. In short, this command
is used to import data into MariaDB. This data could be a backup that we made
previously or completely new data. There are several options, but the basic syntax is
as follows:
mysqlimport [--local] [-u username] [-p] database_name filename
The filename attribute must be the name of the table we want to import into. The
--local option tells mysqlimport to read from the local filesystem instead of from
the data directory of the server.
Here is an example importing the employees.txt file that we generated earlier:
sudo mysqlimport --local -u root -p test /tmp/employees.txt
Any records that cannot be imported will be skipped and not imported, and
mysqlimport will report this and generate a warning. An example would be if our
file has a column in it that contains values that must be unique in our database and if
some of them match the existing records in the database.
Full documentation of the mysqlimport utility is found at https://mariadb.com/
kb/en/mysqlimport .
Making backups of MyISAM tables quickly
with mysqlhotcopy
The mysqlhotcopy backup program is actually a Perl script. It can make backups
quickly, but only if our tables use the MyISAM or ARCHIVE storage engines. The
default storage engine for MariaDB is InnoDB , so this script is less useful than it
used to be back when MyISAM was the default storage engine. If we do have the
MyISAM tables, however, it remains a useful tool.
The basic syntax of the mysqlhotcopy command is as follows:
mysqlhotcopy db_name [/path/to/new_directory]
If a path to a new directory is not given, mysqlhotcopy will make the backup in the
MariaDB data directory.
Other limitations are that the command must be run by a user that can read the
data files in the data directory, and when connecting to MariaDB, if we use a
password, we must specify it on the command line or specify it in a my.cnf file as
mysqlhotcopy does not support prompting us for the password.
 
Search WWH ::




Custom Search