how to access MySQL on OpenShift without rhc port

2019-08-31 01:19发布

问题:

We have a Web Server in our company and create a MySQL Server on OpenShift.

We need to use Python to access the database server without rhc port forward,

Can we have others way to access MySQL on OpenShift directly?

thanks

回答1:

You can access the gear directly just as you would any other Database not housed on OpenShift.

When you created the MySQL cartridge you should have been given a connection string:

mysql://OPENSHIFT_DB_GEAR_DNS:OPENSHIFT_DB_PORT/...

You can use that provided connection string and authentication to access the application.

Note: These strings above are environment variables on the gear, and will typicaly translate to something like:

mysql://app-namespace.rhcloud.com:55582/

This can be used from outside of the gear by other applications to access the database that is hosted on OpenShift.

Note: The OpenShift forums have lots covering this topic.