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

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

Related

I get an error EHOSTUNREACH when trying to connect 1 openshift application in NodeJS with MySQL of another openshift application

I have 2 applications on OpenShift: 1 with MySQL, and 1 with NodeJS that is going to connect to MySQL of the other app.
I've seen examples but none of them seem to work, these are the steps I'm taking:
rhc ssh -a mydbappname
then i get the enviroment variables with
env | grep MYSQL
I get something like:
OPENSHIFT_MYSQL_DB_HOST=127.XX.XXX.X
OPENSHIFT_MYSQL_DB_PORT=3306
After that i try to use those on the other app, but it always throws EHOSTUNREACH, no matter if i create the OPENSHIFT_MYSQL_DB env variables on the Node app and use them, or if i put it directly on the code.
I have seen in other parts that the OPENSHIFT_MYSQL_DB_HOST is something like 54d10be2503e36378e0002db-mydbappname.apps.rhcloud.com.
If I use the port-forward and use 127.0.0.1 with the local port selected for mysql, and start the NodeJS application locally it works, only when i upload the changes to Openshift it fails
In this article:
https://blog.openshift.com/sharing-database-across-applications/
You can read:
"Step 1: Create an application with a database
We will create a scalable PHP application using a MySQL database cartridge. In non-scalable applications, the database will be installed in the same gear as the application. In this case we want the database to be accessible from other gears. So creating a scalable application ensures that the database runs in its own gear that can be accessed from other gears."
So maybe this is the problem, check if this application you created is scalable.

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.

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.

mysql proxy socks

Plain and simple, can anyone explain me how to connect to a mysql server through a proxy (socks4/5). Preferable via the mysql command line (although there are no options for that in the client).
If it's not possible through the mysql command line than ANY other method will work.
All you need is to install and configure tsocks (transparent socks). It's available in most if not all linux distibutions. Afterwards you only need to prefix your command with 'tsocks', for example:
tsocks mysql -h -P .....
To my knowledge, it can't be done through the command line because the mysql command does not support proxy connections.
If both client and server are on a UNIX machine and one of them is accessible from the outside, I suggest using an SSH tunnel. It's basically a securely tunneled TCP connection that can be used for anything and the local mysql command can connect to the tunnel port easily.
If that's no option, you could write some kind of wrapper executable. For example, Java and Ruby have libraries that enable you to talk to SOCKS proxies and hook those sockets up to a MySQL or JDBC protocol implementation. What happens then depends entirely on what you have planned next.
If you've got admin access to the proxy server would there be much mileage in installing MySQL Proxy on it?