Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h1>MySQL</h1> <p>(Instructions for PostgreSQL are further down the page)</p> <p>A temporary workaround would be to directly dump the data from your DB server and load it manually yourself. I have both databases (on Heroku and locally) in MySQL, so I did:</p> <pre class="lang-sh prettyprint-override"><code>1. mysqldump -h host -P port_number -u user_name_to_your_db -p your_db_name &gt; data.sql </code></pre> <p>Once you run the above command with correct details you will be asked to enter your password.</p> <p><strong>NOTE</strong>: Never put your password into your shell command as it is being stored in shell commands history.</p> <p>Get your <code>username</code>, <code>password</code>, <code>your_db_name</code>, <code>host</code> and <code>port_number</code> from Heroku config:</p> <pre class="lang-sh prettyprint-override"><code>2. heroku config --app your-app-name | grep DATABASE_URL </code></pre> <p>Your <code>DATABASE_URL</code> will look like this:</p> <pre class="lang-sh prettyprint-override"><code>mysql2://username:password@host:port_number/your_db_name </code></pre> <p>An example of a bit more real <code>DATABASE_URL</code> will look like this (the login details there are modified):</p> <pre class="lang-sh prettyprint-override"><code>mysql2://afdgsdfghliue:ESIJAFDG-sAFsgiags3464@ec2-34-15-23-232.compute-2.amazonaws.com:5432/9twgsenr8543 </code></pre> <p>In that case the details would be respectively (remember, these are fake ones):</p> <pre class="lang-sh prettyprint-override"><code>username: afdgsdfghliue:ESIJAFDG password: ESIJAFDG-sAFsgiags3464 host: ec2-34-15-23-232.compute-2.amazonaws.com port: 5432 database: 9twgsenr8543 </code></pre> <p>When you run the <code>mysqldump</code> with correct details as shown in <code>1.</code> you will have your data stored in data.sql locally. Now to load it to your local database (we are still talking about MySQL) you will need to run:</p> <pre class="lang-sh prettyprint-override"><code>mysql -u your_local_db_username -h 127.0.0.1 -p your_local_db_name &lt; data.sql </code></pre> <p>The local database login details you should have.</p> <h1>PostgreSQL</h1> <p>I haven't checked the below instructions myself, so please use them together with your brain ;-)</p> <p>I found from </p> <pre class="lang-sh prettyprint-override"><code>pg_dump --help </code></pre> <p>that you could run similar commands to dump your PostgreSQL database from Heroku like this:</p> <pre class="lang-sh prettyprint-override"><code>pg_dump -h host -p port -U username -W your_db_name &gt; data.sql </code></pre> <p>Your <code>DATABASE_URL</code> will start with <code>postgres</code>:</p> <pre class="lang-sh prettyprint-override"><code>postgres://username:password@host:port_number/your_db_name </code></pre> <p>Based on</p> <pre class="lang-sh prettyprint-override"><code>psql --help </code></pre> <p>here is how to load your local PostgreSQL database from the <code>data.sql</code> file prepared above:</p> <pre class="lang-sh prettyprint-override"><code>psql -h 127.0.0.1 -U your_local_db_username -W -d your_local_db_name -f data.sql </code></pre> <p>A bit of manual process, but it at least gets you going.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload