Openshift: How to remote access MySQL?

前端 未结 5 1701
旧巷少年郎
旧巷少年郎 2020-12-12 18:45

So I just finished setting up a JBoss application server gear on Openshift and I attached a MySQL and phpmyadmin cartridges. My question is if there is a wa

相关标签:
5条回答
  • 2020-12-12 18:55

    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.

    0 讨论(0)
  • 2020-12-12 18:58

    Use SSH and MysqlWorkbench

    SSH commands: (next to 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

    Fill SSH hostname = host of yor app, ex: "myappname-user.rhcloud.com"

    SSH Username = UUID of your app

    SSH Key file = On Windows: C:\Users\XXX.ssh\id_rsa On OS X: /Users/XXX/.ssh/

    Click "Test connection" .... and use myqlworkbench

    0 讨论(0)
  • 2020-12-12 19:05

    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.

    0 讨论(0)
  • 2020-12-12 19:06

    Login via SSH.

    1. Login for SSH
    2. export | grep MYSQL
    3. View value to OPENSHIFT_MYSQL_DB_HOST and 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"
    
    0 讨论(0)
  • 2020-12-12 19:08

    The solution is explained here using Linux:

    rhc port-forward -a app &
    
    rhc app show -a <app>
    
    mysql -u <user>  -h 127.0.0.1 -P 3307 -p
    

    After entering your password, you are connected with remote mysql on Openshift.

    0 讨论(0)
提交回复
热议问题