How to tunnel for MySQL using vmc in cloudfoundry? - mysql

I'm just starting out with CloudFoundry and I understand that the only way to be able to execute a sql dump against a db is to
Create MySQL service
Bind Service
Tunnel to the service
But I'm not getting any luck on the last part. I followed the directions from cloud foundry forum discussion
I select option 1. None But I just don't know how run
mysql --protocol=TCP --host=localhost --port=10000 --user=ub2sCBQ0mGsVZ --password=pRXana7vEOX0C df83386088ffc4f8d8cf288791d22fb99 < sample.sql
from command line (Windows) or from SQLyog.
The other part of the question is of course once I am able to create the database and the tables and insert data into them. How does my webapp need to connect to the database?
On one hand I think I know the answer as described here
But I can't believe that this is the only way. This is damn difficult with Spring because I would have to read the env in before the entire Spring/Hibernate machinery starts creating the needed beans. Is there an example of less complex way to do this ?

if you are using Windows I would suggest using MySQL workbench to connect using the credentials provided when opening the tunnel using VMC. You can download it from the MySQL website here;
https://www.mysql.com/products/workbench/
When deploying a Spring application that uses a MySQL service you can have it automatically configure the database connection in your app. See the following page for details;
http://docs.cloudfoundry.com/frameworks/java/spring/spring.html#determining-whether-your-application-can-be-auto-configured

Related

How do I remotely access an SQL database?

This question has been edited for clarity...
Say I have a MySQL database, what are my options for performing queries from a remote computer and having access to the resulting data.
A convoluted solution I can think of is to have a web service that receives a query from a request and responds with an xml file of the results, but this seems like a bad way of doing it. What other options do I have of accessing a database remotely?
So, if you are going to write a Java application to connect to a MySQL database you have a few options:
use JDBC directly as described here: https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-usagenotes-basic.html
Hibernate (http://docs.jboss.org/hibernate/orm/current/quickstart/html_single/) but that may be a little bit too complicated
Spring Data, here is a nice tutorial: https://spring.io/guides/gs/accessing-data-mysql/
JDBI (http://jdbi.org/) extremely simple ;)
There are 2 ways to do it.
1)
mysql -u {username} -p{password} -h {remote server ip} {DB name}
2)
In Windows :
-- Login to another system using putty or rdesktop
-- Access mysql database after login
In Linux:
-- ssh to another system using "ssh user#ip"
-- Access mysql database after login
You can follow this link for more details:
https://support.rackspace.com/how-to/mysql-connect-to-your-database-remotely/
https://dev.mysql.com/doc/refman/5.7/en/connecting.html
If you are using windows machine you can use MySQL Workbench and then you can just provide the details of the server where MySQL is hosted.
You can also use putty to do SSH if MySQL server is hosted in Linux.
Steps:
List item
SSH to the Server where MySQL server is hosted.
mysql -u root -pyourpassword.

How to take backup of MySQL database in Bluemix?

I am using IBM Bluemix MySQL database as a DB server, but I don't know how to take backup from it.
In the past I used to do that with CF tunneling option, but the new CF tool doesn't support CF tunnel.
Some services, like the experimental mysql service on Bluemix are not able to be accessed from outside of Bluemix. You can only access them from within a Bluemix cloud foundry application. If you are using this service , you will need to deploy a phpmyadmin application and bind it to that database to perform management operations.
If you are using other mysql services like cleardb, see Jeff's answer
You will need to get the connection information for the database. You can get this from the UI or the command line.
If you do this from the command line, run cf e appname. It will return the connection information for the db. You can also get it from the UI, if you click on "Show Credentials" it will give you the connection information as well.
Once you get this you can use any MySQL browser to grab the data. You can also grab it with the following command.
mysqldump [options] db_name
See this for more info.

MySql Workbench - difference between "Local instance 3306" and "Localhost via pipe"?

Im learning how to build a simple web app using PHP and MySQL. Tools:
-XAMPP for database, web and php servers
-Sublime for writing the code itself
-Mac OSX Yosemite
- Workbench for database creation
I'm having trouble understanding (and finding a good tutorial) how Workbench actually works. If I got things correctly, I need to create a connection between the Workbench (tool) and the database which sits "inside" the database server? In my case, provided by XAMPP.
After I get these two talking, I then create, edit, etc. tables inside this database, right?
Currently I have two MySql connections on the homescreen, please see attached file.
Thanks!
It's basically just the connection/transfer method. You can connect to a MySQL server via a named pipe if such ability is provided by the operating system OR via TCP connection which is generally for network access but also works and is widely used for localhost connections.
It is transparent to the user and should not affect the communication between server and the client. Those two will connect to the same database using different types of communication channels.

How to use Navicat to connect to the MySQL database in Openshift

I'm using openshift to build my apps.
And I add mysql to my gear.
but, if I want to reach my database. I can't use Navicat which is my usual way to manage my database. I must ssh to my openshift server and then use command line 'mysql' to reach my database which is a bad way compared to Navicat.
So, how can I reach my database in Openshift with Navicat?
I've used env | grep MYSQL to get my mysql configration and use it in Navicat.
However, all is none effect.
If its a scalable application you should be able to connect to it externally via the connection information supplied by the environment variables. If its not a scalable app, then you'll need to use the rhc port-forward command to forward the necessary ports needed to connect.
Take a look at the following article here for more information. https://www.openshift.com/blogs/getting-started-with-port-forwarding-on-openshift

Figuring out MySQL data information on an ec2 instance

I installed MySQL on an EC2 instance and need to get some information about that database so I can setup pligg on it.
The info it needs are: Database Name, Username, Password, Database Server and Table Prefix. Is there a simple way to retrieve this information? I assume I need to use PuTTy but I couldn't find specific info on it.
Thanks
The database server is most likely to be localhost and the rest are values that you must set. The docs for whatever application you are installing should give a tutorial on how to create these.
You might find phpMyAdmin useful if the application provides a SQL script to run and you don't want to use the command line.