How to deploy local MySQL database to Heroku

后端 未结 3 1495
挽巷
挽巷 2020-11-29 20:30

I\'m new to using Heroku and I have a Ruby/Sinatra app in which I plan on using a MySQL database as the main data store.

However, I do not want to write results dir

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 21:03

    I wrote a short article

    https://medium.com/@michaeltendossemwanga/import-mysql-database-to-heroku-with-one-command-import-db-sql-a932d720c82b

    Here is a batch script to fasten the process https://gist.github.com/MichaelTendoSsemwanga/f013963092e3abcce801834871d14b03

    Save this batch script as import.bat

    @echo off
    heroku config | findstr CLEARDB > config.txt
    set /p url=> config.txt
    
    set "x=%string:@=" & set "substring=%"
    set "host=%substring:/=" & set "x=%"
    echo Host:      %host%
    echo Host:      %host% >> config.txt
    
    set "x=%string::=" & set "substring=%"
    set "password=%substring:@=" & set "x=%"
    echo Password:  %password%
    echo Password:  %password% >> config.txt
    
    set "x=%string:://=" & set "substring=%"
    set "user=%substring::=" & set "x=%"
    echo User:      %user%
    echo User:      %user% >> config.txt
    
    mysql -u %user% -p%password% -h %host% -D %dbname%  < %1
    

    In the heroku app directory, run

    import db.sql
    

    Command line output

提交回复
热议问题