简体   繁体   中英

Restoring mysql dump text file to database

I am working with analysing big data using opencl. I got the data in mysql dump text file (dump.txt). I want to restore the data into mysql database. Then I can connect to the database and do the other stuff related to parallel programming to analysis big data.

I went through some tutorials and questions related this. I found a related question here. link here . But there they mentioned the way to restore .sql dump file. what can we do for dump text files?

Abstract part of my dump text file is here

"94723605719","435035","2013-06-01 23:51:36","2013-06-01","2013","6","1","7","22 ","23","51","36","1","202","-1002409728","1005823215","50000.000",\\N,"1613003749 10","50026.000","226","0","0","94723605719","34399725","0","0","0",\\N "94722616878","435014","2013-06-01 23:51:52","2013-06-01","2013","6","1","7","22 ","23","51","52","1","202","-1002099361","1005511506","50000.000",\\N,"1613002394 31","50127.000","157","0","0","94722616878","34438596","0","0","0",\\N "94726556777","435022","2013-06-01 23:51:52","2013-06-01","2013","6","1","7","22 ","23","51","52","1","202","-1002496570","1005910182","50000.000",\\N,"1614002967 42","61046.000","226","0","0","94726556777","34399744","0","0","0",\\N

Any help is appreciated. Thanks in advance.

If you have 'real' dump, then you can use:

mysql -u root -p -h local host < your_dump.sql

That said, your example listed in the question seems to hint that you just have the values in a CSV file, in which case you need to first create the table and then load the data into it:

LOAD DATA INFILE 'your_file.txt' 
 INTO TABLE your_table 
 FIELDS TERMINATED BY ',' 
 OPTIONALLY ENCLOSED BY '"';

See MySQL manual for LOAD DATA INFILE for more details.

I'm used to migrate MySql databases and the best way for me is like this:

Export Database(backup):

mysqldump -u root -p [database_name] >  [dump_filename].sql

Import Database:

mysql -u root -p [database_name] < [dump_filename].sql

If the database you want to restore doesn't already exist, you need to create it first.

On the command-line, if you're in the same directory that contains the dumped file, use these commands (with appropriate substitutions):

C:\> mysql -u root -p

mysql> create database mydb;
mysql> use mydb;
mysql> source db_backup.dump;

https://dev.mysql.com/doc/mysql-backup-excerpt/5.6/en/using-mysqldump.html

http://meta.wikimedia.org/wiki/Database_dump_and_restore_examples

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM