php - Openshift MYSQL Cartige IP
My scalable osclass app need IP address of MYSQL.I try every thing to find out MYSQL IP but not get it. Following things i tried to find IP:
rhc port-forward -a <appname>
command but it show openshift IP address ofHAPROXY
andhttpd
not for Mysql.http://i.stack.imgur.com/Plujm.pngThen buddy niharvey suggest me to ssh into app and type command
env | grep MYSQL
but result still not show ip address
(3) I even Type URL of MySQL instead of IP what i get from 2 try in osclass database setup page but it not working.
(4) I also try https://www.openshift.com/forums/openshift/how-install-custom-wordpress-setup-on-openshift-server method and edit config-sample.php file of osclass. as wordpess and osclass quite similar but that also not works.
I also post thread on openshift but no reply:(
My question how i get this.I think OPENSHIFT team also allow free tier user to Add PHPMYADMIN for scalble app.
Answer
Solution:
Since you are using a scalable application, your IP is actually a fully qualified domain name, you need to use the values of the OPENSHIFT_MYSQL_DB_HOST and OPENSHIFT_MYSQL_DB_PORT environment variables that are shown above.
AND< you should remove that screenshot, since scalable applications database gears are available to all gears on openshift, you are broadcasting your username and password to everyone on the internet...
And if this is your thread on openshift (https://www.openshift.com/forums/openshift/cant-connect-to-database) we did reply to you, you failed to give any details in your forum thread for us to be able to help you.
Answer
Solution:
SSH into your app using command
rhc ssh <app>
after ssh into your app, type inenv | grep MYSQL
then findOPENSHIFT_MYSQL_DB_HOST
and copy the value it has something like thisOPENSHIFT_MYSQL_DB_HOST = 56********************43-<domain>.rhcloud.com
you need the second part, which is56********************43-<domain>.rhcloud.com
then while you are still inside the shell (ssh) of your app, ping the address you just got,ping 56********************43-<domain>.rhcloud.com
. the resulting IP is the MYSQL server IP. I usually use the port inOPENSHIFT_MYSQL_DB_URL
attached to the ip.This may (not sure) differ in different apps.
You can extract the value of
OPENSHIFT_MYSQL_DB_URL
from theenv | grep MYSQL
command I described above.The value is something similar to this
OPENSHIFT_MYSQL_DB_URL=mysql://<MySQLusername>:<MySQLpassword>@56********************43-<domain>.rhcloud.com:61836
You could extract all the required info from here too.
Good luck on using it!