Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql uses mysqldump and mysqlimport for database migration

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Mysql uses mysqldump and mysqlimport for database migration Export the test library in cmd: mysqldump-uroot-p404-- tab='/home/pw/' test import the test library: first execute the sql in the test folder to create the table structure, and then restore the data mysqlimport-uroot-p404 test / home/pw/dept.txt / home/pw/emp.txt Note: if the data file conflicts with the primary key in the table with the mysqlimport plus-replace option, the rows in the data file will be used to replace the existing table. Add-ignore will not be replaced, nothing will report an error. = = mysqldump has two output modes 1) add-- tab=path option: output the tbl.sql containing the "create table" statement and the tbl.txt file containing the data to the specified directory path, first execute tbl.sql with mysql during recovery, and then execute tbl.txt with mysqlimport

2) No-- tab: output an executable script containing create table and insert statements, and restore it with mysql.

Shell > mysqldump db_name > backup-file.sql

Shell > mysql db_name < backup-file.sql

=

Import and export data with select...into outfile and load data infile

Example:

SELECT a dagger, bjorn, a babe INTO OUTFILE'/ tmp/result.txt'

FIELDS TERMINATED BY', 'OPTIONALLY ENCLOSED BY' "'

LINES TERMINATED BY'\ n'

FROM test_table

=

LOAD DATA INFILE 'ls.dat' INTO TABLE T1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report