Openshift:如何远程访问 MySQL?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19749599/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Openshift: How to remote access MySQL?
提问by Stephn_R
So I just finished setting up a JBoss application server gear on Openshift and I attached a MySQL and phpmyadmincartridges. My question is if there is a way to remote access to the database server using an app like MySQL Workbench?
所以我刚刚在 Openshift 上完成了一个 JBoss 应用服务器设备的设置,并附加了一个 MySQL 和phpmyadmin 模块。我的问题是是否有办法使用MySQL Workbench 之类的应用程序远程访问数据库服务器?
采纳答案by Paul Morie
You can use rhc port-forward
to forward ports from your database to your local machine. Check out the tutorial here. The basic idea of port forwarding in this context is that you can forward ports on your local machine to ones on the gear. So in your case, you would forward some port on your local machine to the port mysql is listening on for connections in your gear. Then you would connect MySQL Workbench to the port on your local machine.
您可以使用rhc port-forward
将端口从数据库转发到本地计算机。在这里查看教程。在这种情况下,端口转发的基本思想是您可以将本地机器上的端口转发到设备上的端口。因此,在您的情况下,您会将本地计算机上的某个端口转发到 mysql 正在侦听您的设备中的连接的端口。然后将 MySQL Workbench 连接到本地机器上的端口。
回答by Bhasckar Belo
Use SSH and MysqlWorkbench
使用 SSH 和 MysqlWorkbench
SSH commands: (next to rhc ssh myappname)
SSH 命令:(在 rhc ssh myappname 旁边)
echo $OPENSHIFT_MYSQL_DB_HOST
echo $OPENSHIFT_MYSQL_DB_PORT
echo $OPENSHIFT_MYSQL_DB_USERNAME
echo $OPENSHIFT_MYSQL_DB_PASSWORD
MysqlWOrkbench
工作台
Create new connection:
创建新连接:
Set connection name
设置连接名称
set connection method: Standard TCP/IP over SSH
设置连接方式:标准 TCP/IP over SSH
Fill SSH hostname = host of yor app, ex: "myappname-user.rhcloud.com"
填写 SSH 主机名 = 你应用的主机,例如:“myappname-user.rhcloud.com”
SSH Username = UUID of your app
SSH 用户名 = 您应用的 UUID
SSH Key file = On Windows: C:\Users\XXX.ssh\id_rsaOn OS X: /Users/XXX/.ssh/
SSH 密钥文件 = 在 Windows 上:C:\Users\XXX.ssh\id_rsa在 OS X 上:/Users/XXX/.ssh/
Click "Test connection" .... and use myqlworkbench
单击“测试连接”....并使用 myqlworkbench
回答by Timo
回答by Sergio
Login via SSH.
通过 SSH 登录。
- Login for SSH
- export | grep MYSQL
- View value to OPENSHIFT_MYSQL_DB_HOST and OPENSHIFT_MYSQL_DB_PORT
- 登录 SSH
- 出口 | MYSQL
- 查看 OPENSHIFT_MYSQL_DB_HOST 和 OPENSHIFT_MYSQL_DB_PORT 的值
Example:
例子:
[xxxxxxx.rhcloud.com xxxxxxx]\> export | grep MYSQL
declare -x OPENSHIFT_MYSQL_DB_GEAR_DNS="xxxxxxx-name.rhcloud.com"
declare -x OPENSHIFT_MYSQL_DB_GEAR_UUID="xxxxxxx"
declare -x OPENSHIFT_MYSQL_DB_HOST="xxxxxxx-name.rhcloud.com"
declare -x OPENSHIFT_MYSQL_DB_PASSWORD="nlxxxxxxx"
declare -x OPENSHIFT_MYSQL_DB_PORT="57176"
declare -x OPENSHIFT_MYSQL_DB_URL="mysql://adminxxxxxxx:nlqxxxxxxx-name.rhcloud.com:57176/"
declare -x OPENSHIFT_MYSQL_DB_USERNAME="adminxxxxxxx"
回答by user518066
To remotely access MySQL on Openshift, you can configure NodePort or LoadBalancer as the type on the Service instead of the default ClusterIP. This will allow external tcp access to your database. Note a nodeport will be defined in the 30000-32767 range by default which will map to the targetport.
要在 Openshift 上远程访问 MySQL,您可以将 NodePort 或 LoadBalancer 配置为服务上的类型,而不是默认的 ClusterIP。这将允许外部 tcp 访问您的数据库。请注意,默认情况下将在 30000-32767 范围内定义一个节点端口,它将映射到目标端口。