Reputation: 672
I want to import a .sql file so that my new schema and datas is the one and the .sql file (so I don't care about losing my current schema and datas)
I tried rails db < sql-file-path
but it returns me an error :
I've found this answer but it's not clear what this is really doing, like we have to create a migration to execute ruby code and import a file ? Every solution is welcome :)
Upvotes: 0
Views: 3062
Reputation: 6381
In this case I would follow these steps:
Recreate the schema.rb file from the database
bundle exec rake db:schema:dump
Upvotes: 0
Reputation: 3398
You don't need do necessarily with rails. You can use only mysql if you're comfortable with it. You can access mysql console by:
mysql -u user_name -p
Exchange "user_name" by your user (root for example), then it will ask for your user password. When you have access to the console, you can select your development database by:
use your_database_name;
and then, to import:
source your_sql_file.sql
You can check your credentials and your database name on your database.yml
.
If it doesn't work, please check your sql syntax or try to generate the dump file again.
Good luck, hope this helps!
Upvotes: 2