LOAD DATA INFILE
LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name' [REPLACE | IGNORE] INTO TABLE tbl_name [CHARACTER SET charset_name] [{FIELDS | COLUMNS} [TERMINATED BY 'string'] [[OPTIONALLY] ENCLOSED BY 'char'] [ESCAPED BY 'char'] ] [LINES [STARTING BY 'string'] [TERMINATED BY 'string'] ] [IGNORE number LINES] [(col_name_or_user_var,...)] [SET col_name = expr,...]
EJEMPLO 1:
CREATE TABLE t1 (a int, b int, c int, d int); LOAD DATA LOCAL INFILE '/tmp/loaddata7.dat' into table t1 fields terminated by ',' (a,b) set c=a+b; SELECT * FROM t1; +------+------+------+ | a | b | c | +------+------+------+ | 2 | 2 | 4 | | 3 | 3 | 6 | | 4 | 4 | 8 | | 5 | 5 | 10 | | 6 | 8 | 14 | +------+------+------+
EJEMPLO 2: MariaDB [db_name]> load data infile ‘file_name.txt’ into table tb_name fields terminated by ‘|’ ;
VER ESTRUCTURA DE UNA TABLA: MariaDB [db_name]> describe tb_name;
UBICACION DE BD MYSQL: /var/lib/mysql/
Fuente: https://mariadb.com/kb/en/load-data-infile/
Restaurar BD Mysql: #mysql -u user_name –password=123456 bd_name< backup_bd_name.sql