How to push my Mysql database to heroku via mysql workbench? - mysql

I have created cleardb on heroku, I want to push my mysql database on local disk to heroku. I have mysql workbench installed. How can i push it to heroku ?

look at the output of heroku config - you will see an key called CLEARDB_DATABASE_URL this is the connection string your application uses to talk to your database.
You can take this URL and break it up into it's constituent parts to get a username, password, host, port and database name which you can use in a connection via mysql workbench.
See https://devcenter.heroku.com/articles/cleardb for further reference.

If u want to just push your database, use console, it's simple:
heroku db:push

Related

How to reconnect from workbench to heroku app?

I have made a React+Node application with MySQL database. I'm using Heroku to deploy my application, and have done so successfully. However, I'm having problems with using my database on Heroku. Locally I'm using XAMPP and phpmyadmin for all database work.
In Heroku, I've used a clearDB add on to support MySQL and have gotten all necessary credentials in the format:
mysql://DB_USERNAME:DB_PASSWORD#BD_HOST/DB_DATABASE?reconnect=true
I've used MySQL Workbench and have created a database using the above supplied host name, username, password and have successfully connected the database to the app. But after a while i changed (on PhpMyadmin) the database structure and i deleted the connection from workbench panel. I tryied to make a new connection with the same Config Vars but the workbench send me an error of "Unknown Database nameOfDatabase".
There is something i missing? there is anything i have to do to delete the old connection for the new one to work?
thanks!

How to switch from MySQL to Postgre on Heroku

I want to host a django project on heroku. Locally, I developed it using MySQL database. And I have also pushed it to heroku but I get an Error message whenever I run heroku open command on command prompt. The error message is Can't connect to local MySQL server through socket. Though I'm a newbie in using databases, the way I understand the error is that heroku can't connect to local MySQL server which I'm using for local development. I don't want to connect to a remote MySQL database, instead, I want to connect to Postgre database just as heroku recommended.
Being a newbie in the use of database, I don't know the best way to migrate to Postgre or how to add MySQL in my project to .gitignore. Is it possible for me to start running Postgre on heroku while MySQL isn't added to . gitignore and is still the database in settings.py? Must I clear MySQL database or add it to gitignore before I can use Postgre?
PostgreSQL settings for Heroku:
Please install dj_database_url using below command:
pip install dj-database-url
In settings.py , import dj_database_url and add below settings at the end of the file:
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
Done !! Now, deploy again to Heroku.

How to import a MySQL db to OpenShift?

I've been working on a JSP project and now I want to host in on Openshift. Everything is set up except for the database. I already added MySQL 5.5 cartridge and phpMyAdmin 4.0 and I edited the credentials in my project as shown below. But how can I upload my database data to the application?
Constants in my project
Apparently, the key was to replace the variables in the DB URL with the openshift variables.
To upload your data into your database you could use a tool to manage you tables (for example Squirrel-SQL). To connect it with your openshift-database enable the port-forwarding through your rhc console so you can access the database as it would be a local one and connect to it through squirrel. (you cannot connect direcly to the remote database from openshift - only with port-forwarding)
rhc <app-name> port-forward

How to browse data in MySQL database on Amazon EC2?

I deployed my Rails app to Amazon EC2 server (Ubuntu), but I am thinking how to connect to MySQL database from terminal (SSL) and manually check data in database.
How to do that? I see in the database.yml file some credentials, but don't know how to connect/log in into MySQL on EC2 instance.
Thanks
There's no special magic involved here. An EC2 server is just... a server. This is not hosting like heroku or godaddy where your database is going to be hosted on a different db server.
Unless you explicitly setup a separate db server (which I don't think you did), you've got an entire virtual machine running Ubuntu, and the db server is most likely running on the same machine.
So you can ssh into the machine and just run the standard mysql client. Docs here: http://dev.mysql.com/doc/refman/5.6/en/mysql.html.
If you want to use some gui software such as sequel pro mentioned in one of the comments, you'll need to open up the ports in the aws console. Amazon closes all the ports by default. Do this to open up the port:
Open up the AWS control panel
Go to 'Security Groups'
Select the security group in the panel (you probably only have one).
Click the 'Inbound' tab.
Select Mysql from the dropdown list
Save the rule
This will open up port 3306 and enable you to use an external tool to see the server.
If you just want to call some sql to the database just to verify small amount of data, you can try doing these:
sql_statement = 'SELECT * FROM users'
ActiveRecord::Base.connection.execute(sql_statement).to_a

Grails DataSource for remote MYSQL database access and migrations

Is it possible for locally running grails application to access and update remote MySQL db?
Assume the remote server is linux on which tomcat, MySQL are installed in the usual places.
Assume remote URL is accessed as tom#189.124.24.249. So grails needs to access the db as the user 'tom' or does it need to be the root user or mysql user??? Does the password of user tom need to be specified in the DataSource.groovy? In MYSQL the db test_db is configured to be accessed with user name 'guru' and password 'secret'.
If the same grails application is also running on the remote server accessing that remote db, a locally running instance of grails application accessing the same remote db should not cause any problems??
Assume the remote db name is test_db.
I need this also in context with liquibase grails plugin and database migrations. I need to run grails migrate command against the remote db to synchronize it with local db.
A side question: how do I synchronize local db in which table data is already populated to remote fresh newly created db with no data? This seems to fall under the domain of db content migrations which is not covered by the grails plugin as far as I know. I would like to know what would be the correct approach to this in the context of a grails application.
you just need to set the proper credentials in the Datasource.groovy and it all should work fine. We are running our app in a production environment and the database server is on a different box.
I dont think that two applications accessing the database server should be a problem.
Can't help with the side question... sorry
I believe, it's mostly a duplicate of Liquibase Grails database migrations
For side question: after Grails migrates structure, mysqldump or whatever backup/restore procedure should work.