Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I import a SQL file into a Rails database?

I've got a .sql file that I'd like to load into my Rails database using a Rake task. How can I do this?

like image 407
Nathan Long Avatar asked Dec 01 '11 14:12

Nathan Long


1 Answers

The easiest way:

bundle exec rails db < $SQL_FILE 

example:

bundle exec rails db < my_db.sql 
like image 129
Abel Avatar answered Sep 21 '22 01:09

Abel