简体   繁体   中英

How can I setup a development mysql database on heroku?

I have setup a working heroku account with all my files and a database here - https://frozen-dusk-2587.herokuapp.com/

I downloaded the .sql file from my production server ( structure only | not actual data ) and want to upload it to Heroku.

How do I do this? I found this article here - How do I push my mysql database from phpmyadmin to heroku's cleardb?

Is this the correct way to do it?

It mentions this command in general which looks like a simple one liner

mysql <dbname> -u <username> -p<password> < <file.sql>

Is it this simple? If so where do I get the dbname, username, and password?

Clicking around Heroku I found this. It looks like my dbname is

heroku_blahblah

If this is correct what do I use for username / password?

As far as I know Heroku doesn't support mysql databases but it does support PostgreSQL. You can basically create a Postgres DB on https://postgres.heroku.com and migrate your mySQL database using one of the available tools. The connection details to your new DB will be accessible from your dashboard.

I created a MySQL add-on that lets you use MySQL on Heroku for free. You can indeed use a one-line command to upload your file (as long as you have mysql installed in the location you are issuing the command from).

To create a mysql database from the heroku toolbelt, try the following:

heroku addons:create jawsdb:NAME_OF_PLAN_HERE --app HEROKU_APP_NAME_HERE

Plans are detailed here

From there you will get a connection string of the form mysql://username:password@hostname:port/database_schema set as a configuration variable in your heroku dashboard. Grab the credentials from there to load your .sql file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM