GiLL
GiLL

Reputation: 354

How to access Openshift mysql via locally installed wamp phpMyAdmin?

i am using openshift free tier (3 gears). My scalable app uses PHP and MySQL. But unavailability of phpMyAdmin credentials for 3 gears scalable app it's difficult for me to access Mysql table entries. My question is can port forward feature of Openshift is used to access openshift Mysql via locally installed wamp phpMyAdmin.

Upvotes: 4

Views: 4422

Answers (5)

Ariel Scarpinelli
Ariel Scarpinelli

Reputation: 310

You can add this cartridge to have phpMyAdmin support in scalable apps:

https://github.com/arielscarpinelli/openshift-scalable-phpmyadmin

Upvotes: 0

eduyayo
eduyayo

Reputation: 2038

Before you open the session with Putty, go to the Connection-->SSH-->Tunneling.

There add a port, for example, 3333. And set as destination the url of your remote mysql server and port, for example: 324324343455435435-yourservices.rhcloud.com:44351. Click on the "Add" button. Save your session and connect.

Once connected you can use whatever the client and connect to localhost on the port 3333 with the user, password and database name given by the env vars as the other guys said. I connect with Toad for Mysql with no problems.

Upvotes: 3

GiLL
GiLL

Reputation: 354

instead of phpmyadmin.SQLyog from webyog has ssh tunneling option. which work fine for remote accessing openshift mysql

Upvotes: 0

user2879327
user2879327

Reputation:

You can use the rhc port-forward command, similar to what i described here: OpenShift: How to connect to postgresql from my PC

Upvotes: 3

Claus Conrad
Claus Conrad

Reputation: 511

Yes, it is possible to use port forwarding to access your OpenShift database from your locally installed PhpMyAdmin.

First, make sure you have the Redhat Client Tools (RHC) installed on your computer. If you haven't, download them here: https://www.openshift.com/developers/rhc-client-tools-install .

In order to connect via SSH, you will need a public/private key pair. Again RHC can automate most of this for you when you run rhc setup. The application will ask for your credentials, optionally create an SSH key for you and upload it to your cartridges. Make sure to protect your SSH key with a secure password. This process is described in more detail at https://www.openshift.com/developers/remote-access .

You will need a SSH client. OpenShift recommends Putty for Windows users; detailed setup instructions can be found at https://www.openshift.com/page/install-and-setup-putty-ssh-client-for-windows . In addition I would recommend to install OpenSSH from Cygwin, as this makes it easier to forward the port to your database later on.

Use Putty and your SSH key to connect to your server via SSH. Once you are at the shell, type env to view a list of environment variables on the server. Look for the variables that end with _DB_HOST, _DB_PORT, _DB_USERNAME and _DB_PASSWORD and make a note of their values on your Windows machine. The names and meanings of all of these environment variables are described at https://access.redhat.com/site/documentation/en-US/OpenShift_Online/2.0/html/User_Guide/Database_Environment_Variables.html .

To forward the port, use Cygwin's ssh command. For example: ssh -f [email protected] -L 3307:DB_HOST:3306 -N

You will have to replace user with your OpenShift username, my-app.openshift.com with your public OpenShift hostname and DB_HOST with the IP address from the ..._DB_HOST environment variable that you looked up above. If this command succeeds, you should now have a tunnel from your local port 3307 to the MySQL server at OpenShift. Thus, you can create a new database connection in PhpMyAdmin's configuration with 127.0.0.1 as the server, 3307 as the port and your credentials, which you got when running the env command via SSH.

Upvotes: 6

Related Questions