How to take backup of MySQL database in Bluemix? - mysql

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.

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

How to tunnel for MySQL using vmc in cloudfoundry?

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

Execute Shell command over MySql on remote host

Is it possible to login into a remote mysql machine and execute commands using 'system' on the remote machine.
I can log into the remote machine, but commands using: 'system' are executed at my local machine.
Thanks indeed!
I using mysql to connect from 'Host1' to 'Host2' using the command
mysql -uUsername -p data_base_name -h Host2
When I execute
'system hostname'
after I'm connected i get.
'Host1'
I cannot log into my remote host using ssh. I don't know why. I need to do some log analysis and the only option I have is to connect to that machine using mysql. I can connect to that machine! –
As far as I know, this is definitely not possible. It's far beyond the scope of mySQL, and there would be immense security implications if it were.
I don't think there is an alternative to getting SSH (or some other service that might help) running again.
Consider doing a select into outfile and writing script code into a place that will be executed on the server. For example, if mysql is running as root on the server, you be able to add something to the /etc/rc2.d which will get executed on the server during boot time.
Alternatively, if there is a file which is used as a source for scheduling tasks you may be able to overwrite that again using "select into outfile."
system runs local commands on your box. If you need to do anything with logs, either contact your hoster, to provide a way to download them or access them.

How to 'switch' from MySQL to Amazon RDS with minimal application impact?

Amazon officially states: "Amazon RDS gives you access to the full capabilities of a familiar MySQL database. This means the code, applications, and tools you already use today with your existing MySQL databases work seamlessly with Amazon RDS."
I don't get this. Amazon RDS is accessible via web services and there a client libraries (like the one for .Net).
So if I have an existing .Net application that uses a DAL which in turn queries MySQL, how can I make the same DAL talk to the Amazon RDS (via the web services). Or am I missing something here?
Amazon RDS is pure MySQL, accessible by your app the same way as any other MySQL database; the web services interface to RDS is purely for creation, deletion, and modification of the DB instances, not the DB data. From their FAQ:
Q: How do I access my running DB
Instance?
Once your DB Instance is available,
you can retrieve its
endpoint via the DescribeDBInstance
API. Using this endpoint you can
construct the connection string
required to connect directly with your
DB Instance using your favorite
database tool or programming language.
In order to allow network requests to
your running DB Instance, you will
need to authorize access. For a
detailed explanation of how to
construct your connection string and
get started, please refer to our
Getting Started Guide.
This is the part of the Getting Started Guide you need -- it explains how to get the hostname of your new instance so you can connect to it, authorize the instance for access from the client, and then connect using the MySQL command-line client (as an example):
$ rds-describe-db-instances --headers
$ rds-authorize-db-security-group-ingress default --cidr-ip 192.0.2.0/30 --headers
$ mysql -h myinstance.crwjauxgijdf.us-east-1.rds.amazonaws.com -P 3306 -u mymasteruser -p
Amazon RDS is just a normal server with normal MySQL access. There's only the webservice that handles instance creation etc., but everything mysql related is still the same.