Grails DataSource for remote MYSQL database access and migrations - mysql

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.

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 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

TeamCity won't create its schema in SQL Server

I've installed a new TeamCity instance and just moved from internal storage to database (SQL Server). Followed the instructions at http://confluence.jetbrains.com/display/TCD7/Setting+up+an+External+Database and I know I've done the database part correctly as it wouldn't initially connect and I had to go back and turn on TCP/IP connections for SQL Server.
From the documentation I assumed that team city would create and maintain it's own database schema, but even though it's user is dbo the database remains blank - no tables, views or any other objects have been created.
When I try to connect to it in a browser I get "Database is empty or doesn't exist", and viewing the logs shows me "Schema contains no tables". I've obviously restarted the service and connected again each time.
Is there an install script I am missing? How do I get TeamCity to install it's schema?
When you are doing it like this, you will need to migrate the initial structure over to sql server. See here

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

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

Create datasource for mysql to different machine in glassfish

I'm using glassfish(v2.11) as my application server and I have another machine for mysql database server. Currently I want to separate the app server and db server, so I create a jdbc datasource to point to mysql server, but it doesn't works as expect, by the way, when I create datasource to point to local machine (glassfish app server and mysql db server in single machine), and It works well.
Is there any configuration I need to care of when pointing datasource to different machine which I use to host my database (MySQL 5.1)?
Besides granting the mysql user you'll connect as the proper rights, specifying the host in the JDBC url, and making sure there's no firewall stopping you (default mysql uses port 3306), there should be no difference.
WOW ...restart glashfish app server and it works .. :)