Dump sql file to ClearDB in Heroku

https://stackoverflow.com/questions/11803496/dump-sql-file-to-cleardb-in-heroku/11803685

Ask QuestionAsked 7 years, 5 months agoActive 4 years, 4 months agoViewed 12k times1516

I have a sql file that I want to be dumped into a MySQL database that I have in Heroku using the ClearDB addon. When dumping in local I do the following:

mysql -u my_user -p mydatabasename < my_dump_file.sql

However, I don't have any clue on how to dump it to the Heroku MySQL database. All I know is this address:

mysql://b5xxxxx7:37xxxad@us-cdbr-east.cleardb.com/heroku_xxxxxx?reconnect=true

But if I try to do:

mysql://b5xxxxx7:37d8faad@us-cdbr-east.cleardb.com/heroku_xxxxxx?reconnect=true < my_dump_file.sql

I get No such file or directory.

How am I supposed to do it?mysql ruby-on-rails ruby herokushareimprove this questionedited Mar 3 '14 at 22:22Ismael Abreu15.2k22 gold badges5353 silver badges7070 bronze badgesasked Aug 3 '12 at 21:24Hommer Smith20k4545 gold badges124124 silver badges228228 bronze badges

  • 1When dumping in local you probably do > and not <, as the latter will actually restore and overwrite mydatabasename. – Magne Dec 10 '14 at 8:32

  • You don't "dump into", you "dump out of" a database. Then you "restore" a database from a dump. – Magne Dec 10 '14 at 8:34

add a comment

2 Answers

activeoldestvotes33

You might be able to do something like this

mysql --host=us-cdbr-east.cleardb.com --user=b5xxxxx7 --password=37d8faad --reconnect heroku_xxxxxx < my_dump_file.sql

shareimprove this answeredited Sep 4 '13 at 10:46answered Aug 3 '12 at 21:41Ismael Abreu15.2k22 gold badges5353 silver badges7070 bronze badges

  • Thanks for that! I didn't use the command line, but it worked perfectly when I connected remotely with Sequel Pro. You're a lifesaver. – Kyle Carlson Feb 5 '14 at 8:51

  • 3use heroku config to get the CLEARDB_DATABASE_URL which contains the info you need for this command, in the format: mysql://user:password@host/heroku_db?reconnect=true. In this case: mysql://b5xxxxx7:37d8faad@us-cdbr-east.cleardb.com/heroku_xxxxxx?reconnect=trueMagne Dec 10 '14 at 10:50

  • I tried following your comment but it gave me this error: REFERENCES command denied to user 'baexxxxxxxxxxx'@'ec2-54-165-50-141.compute-1.amazonaws.com' for table 'ycdb.recipe' Any ideas on how to solve this? – thegreathypocrite Dec 23 '18 at 15:26

add a comment2

It doesn't work for me on the new version of mysql. So I tried following code:

mysql -h us-cdbr-east.cleardb.com -u b5xxxxx7 -p heroku_xxxxxx < my_dump_file.sql 

and then it asks your password.shareimprove this answeredited Sep 9 '15 at 23:30answered Sep 9 '15 at 23:19Hamid Hoseini1,0961111 silver badges1818 bronze badgesadd a comment

Your Answer

Last updated

Was this helpful?