Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL command line import causes sql file to become empty

I have a 8GB sql file called test.sql.

I am running this command to import it into my database called test_db.

mysql -u root -p test_db > test.sql

After a few minutes, the file test.sql is emptied so that it is 0KB.

I am unsure if this is normal and the file will be restored when the command is finished, or if something is wrong. It's been half an hour and I don't see any data imported yet.

Why is test.sql becoming emptied of it's contents when I run this MySQL import command?

I am on Ubuntu 14.04 and MySQL 5.7.13.

like image 456
Goose Avatar asked Apr 07 '26 06:04

Goose


1 Answers

You're using the wrong chevron. Should be the left chevron (<) not the right chevron (>).

This is what you meant:

mysql -u root -p test_db < test.sql
like image 193
Ike Walker Avatar answered Apr 08 '26 20:04

Ike Walker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!