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.
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 user#my-app.openshift.com -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.
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.
You can use the rhc port-forward command, similar to what i described here: OpenShift: How to connect to postgresql from my PC
instead of phpmyadmin.SQLyog from webyog has ssh tunneling option. which work fine for remote accessing openshift mysql
You can add this cartridge to have phpMyAdmin support in scalable apps:
https://github.com/arielscarpinelli/openshift-scalable-phpmyadmin
Related
Good day,
I have a VB application which i need to connect its database in xampp/mysql..
But mysql/xampp is installed to other computer which is networked at my computer.. What will I do?
The MySql server with XAMPP is no different to any other MySql server , with the exception of the interface; it looks a little bit different. If you want to be able to connect to the server, you need to know the server's internal IP address (you can find it with CMD > ipconfig). The port will generally be assigned to 3306, so you shouldn't have any issues there.
If you want to grant access to the server from your computer, open up the XAMPP control panel (from the other computer) and click Shell. Type in MySql and you'll be able to execute commands, from there (which you can use to grant remote access).
There is a server I wish to connect to. It has multiple VMs running on it each VM has a mysql DB. I can currently connect to this server using ssh and then connect to any of the databases from each VM using mysql -u user -h host -p password. Now I want to connect to the same MySQL DBs using MySQL workbench from my local machine. However there is firewall, currently I use putty to get passed the firewall with public private key authentication and I can access any machine I want. I have seen here that I must install a MySQL server locally ( I've done this I am using mysql workbench) and use the loop-back address, in that way you don't need to access an external server. Could anyone point in the right direction on how to do this?
You need to use ssh tunnelling.
In putty under the options go to Connection->SSH->Tunnels. Add a tunnel from source port 13306 to Destination localhost:3306.
You can do this in Putty either before or after you connect. It's best to do beforehand and save the session configuration otherwise it gets tedious having to re-enter the settings.
In MySQL workbench connect to localhost port 13306.
There is a good guide with screen shots here: Setting up an SSH tunnel with PuTTY
An SSH tunnel makes a TCP port on your SSH client machine and directs any traffic to whatever the destination is set to. You can add multiple tunnels, but each one must listen on a different source port number.
You can forward the port via SSH.
ssh -NL is your friend like so:
ssh -NL 3306:localhost:3306 <yourserver>
Then you can point your workbench at localhost.
You don't need any additional software for this task. MySQL Workbench can create SSH tunnels on its own. Watch my tutorial on Youtube how to create connections: https://www.youtube.com/watch?v=DCgRF4KOYIY.
It essentially comes down to creating the right connection type. There is a drop down that allows you to select an SSH connection. Enter the parameters which you used to connect via Putty.
I have a distant web application and DataBase, and I want to do some test in my local machine using the remote Database.
So I changed httpd-xampp.conf -> LocationMatch:
Order deny,allow
#Require local
Allow from ::1 127.0.0.0/8
Allow from xx.xx.xx.xx
And add in my.ini:
skip-name-resolve
Then I restart apache and mysql.
Now I can access to phpmyadmin without problem but not in mysql via command line nor via my web application
How can I remotely access to mysql via command line?
Thank you
Phpmyadmin is not a database. Phpmyadmin is a GUI written in PHP, helping you visually work with your database. The actual database is MySQL. MySQL is running on your remote server, likely, hopefully, behind a firewall. On the same machine is Apache serving phpmyadmin. Apache is accessible to the outside world. Phpmyadmin can access the MySQL database, because it's running locally on the same machine. You cannot connect to the MySQL database from the outside world, because it's behind a firewall and/or doesn't accept random connections from the internet. It has nothing to do with Apache.
And that's good. You should never publicly expose your database to the internet.
The best way to directly connect to a remote database is via an SSH tunnel. For this you need to set up SSH access to your remote system, if you haven't already, and then tunnel using something like ssh -L 9999:localhost:3306 example.com -N. Looks up the specifics in the ssh manual.
Server newbie here!
I have access to an amazon AWS server, and I have a php webservice on my localhost. The php is working properly on the webservice. The MySQL is set up on the server. However, I cannot connect to my server. I set up everything on the amazon AWS server by SSH-ing in to it and working from there. Is there a way to allow me to ssh into the server with my webservice?
Just to reiterate:
-My php script is at localhost/ ...
-My server is accessed by ssh and then on my localhost, it is hosted by amazon aws (default port 3306)
I attempted the process suggested by one user which was to enter the following into my terminal:
ssh -L 8080:127.0.0.1:3306 -f -C -q -N -i ./password.pem user#host.com
and then when I used mysqli connect I entered:
new mysqli('127.0.0.1:8080','root','mypassword');
Thanks so much for any assistance!
It sounds like you are trying to connect to your remote database from your local server (if I understand correctly). You want to double check your security groups in AWS that they are allowing your computers ip address to connect to the server instance / that port 3306 is open to your pc. If that is all set, then you should be able to connect to the instance using the public dns or elastic ip if it is an EC2 instance, or the endpoint if it is an RDS instance.
I have deployed an app on Openshift redhat cloud server. I want to use toad to remotely access my mysql database. I am new to toad and never configured it. I just want to know how can I set it up to access my openshift database? I can create ssh connection to the server using toad, but it requires password and openshift instead provides a private key file to log in to the server. Can anyone help me upon this?
You can use port forwarding to get local access to your database. There's a good blog post on port forwarding here:
https://openshift.redhat.com/community/blogs/getting-started-with-port-forwarding-on-openshift
To get your database username and password, you can ssh into your app and look at the mysql-related environment variables.
$ ssh <uuid>#<appname>-<namespace>.rhcloud.com
[appname-namespace.rhcloud.com ~]\> export | grep MYSQL
You can find the ssh command listed on the app overview page in the console, under the "Want to log in to your application?" link, or by running the rhc app show command.
You'll need to use port forwarding to access the db remotely