Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

terminal command for mysql file import

Tags:

mysql

I am trying to import a 60 MB file, filename-20120201.tbz, into a newly created MySQL database. I am using terminal, and have opened the database by the prompt use new_database.

How do I import this file correctly? I am on a Mac. Thanks.

like image 779
rgb Avatar asked Feb 02 '12 03:02

rgb


People also ask

How do I open a MySQL file in Terminal?

To run SQL files from the terminal, you can use the source or the backslash and dot command ( \. ) Next, enter the password for your root user. The path /Users/nsebhastian/Desktop/test/main. sql above needs to be changed to the SQL file path on your computer.


2 Answers

If you are running mysql and using your newly created database use the below code to run the script file

mysql> SOURCE input_file

or from terminal

mysql -u root -p database < filename-20120201.tbz
like image 105
Naveen Kumar Avatar answered Oct 04 '22 23:10

Naveen Kumar


Try

$ mysql -u root -p new_database < db-dump.sql

Where: new_database is the name of your new database and db-dump.sql is the mysql file to be imported

like image 37
Rezigned Avatar answered Oct 04 '22 23:10

Rezigned