Learn about Centmin Mod LEMP Stack today
Become a Member

Mysql server on separate Node/VPS, How can I connect to it?

Discussion in 'MariaDB & General MySQL news & discussions' started by RoldanLT, Jun 16, 2015.

  1. RoldanLT

    RoldanLT Well-Known Member

    3,978
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    12:23 PM
    1.11
    10.2
    On Linode, I got this:
    On my Nginx/PHP-FPM another Linode, I use 192.168.123.12 as mysql server, But can't connect :/
     
  2. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:23 AM
    1.91
    10.0.19
    You checked the firewall for allow rules (Obvious but thought I would check) Is the server allowed access to the mysql database not just localhost when you granted permission?
     
    • Like Like x 1
  3. RoldanLT

    RoldanLT Well-Known Member

    3,978
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    12:23 PM
    1.11
    10.2
    CSF already white list both VPS.
     
  4. RoldanLT

    RoldanLT Well-Known Member

    3,978
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    12:23 PM
    1.11
    10.2
    When I created the user on MYSQL server Node, I run this:
    123.12.23.45 should be the public IP of the MYSQL server right?
     
  5. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:23 AM
    1.91
    10.0.19
    Should be the public IP of the server thats connecting to it
     
  6. RoldanLT

    RoldanLT Well-Known Member

    3,978
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    12:23 PM
    1.11
    10.2
    So:
     
  7. RoldanLT

    RoldanLT Well-Known Member

    3,978
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    12:23 PM
    1.11
    10.2
    I don't need a mysql server running on the Nginx/php node right?
     
  8. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:23 AM
    1.91
    10.0.19
    I would log into the MySQL server

    Code:
    GRANT ALL PRIVILEGES ON databasename.* TO "thedbuser"@"nginxserverip" IDENTIFIED BY "password";
    Code:
    FLUSH PRIVILEGES;
    On the nginx server mysql can be shut down
     
    • Like Like x 1
    • Informative Informative x 1
  9. RoldanLT

    RoldanLT Well-Known Member

    3,978
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    12:23 PM
    1.11
    10.2
    I can connect now, Thanks!
    but how to use the Private/Local IP instead of the public?
     
  10. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:23 AM
    1.91
    10.0.19
    :)
    Aslong as there is connectivity between them firewall allow for the private IP's and MySQL is listening on 0.0.0.0. You can just grant access same as above using the Private IP
     
  11. RoldanLT

    RoldanLT Well-Known Member

    3,978
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    12:23 PM
    1.11
    10.2
    I can't even ping the private IP of Mysql server on Nginx server.
    Why is that?
    I already whitelist it on CSF.
     
  12. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:23 AM
    1.91
    10.0.19
    Hmm is the IP added to the VPS's can you see the IP when you run

    Code:
    ifconfig
     
  13. RoldanLT

    RoldanLT Well-Known Member

    3,978
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    12:23 PM
    1.11
    10.2
    I thought it will be auto added when installing an image.
    I don't see it :/
     
  14. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:23 AM
    1.91
    10.0.19
    Think they need to be added manually

    Edit / Create
    Code:
    /etc/sysconfig/network-scripts/ifcfg-eth0:1
    Add the content below but changing the relevant info from the linode manager

    Code:
    # Configuration for eth0:1
    DEVICE=eth0:1
    BOOTPROTO=none
    
    # This line ensures that the interface will be brought up during boot.
    ONBOOT=yes
    
    # eth0:1
    # This is a private IP address. Private IPs do not have a gateway (they are not publicly routable).
    # All you need to specify is the address and netmask
    IPADDR=192.168.133.234
    NETMASK=255.255.128.0
    Restart networking

    Code:
    service network restart
    Sorry if its a bit of an dummy guide :eek:
     
    • Informative Informative x 1
  15. RoldanLT

    RoldanLT Well-Known Member

    3,978
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    12:23 PM
    1.11
    10.2
    This will not set it auto?
    [​IMG]
     
    • Informative Informative x 1
  16. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:23 AM
    1.91
    10.0.19
    That may do it :), Sorry never used any of Linode's services :cry:
     
  17. RoldanLT

    RoldanLT Well-Known Member

    3,978
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    12:23 PM
    1.11
    10.2
    Thanks!
    I see it now on ifconfig
    Code:
    # ifconfig
    eth0      Link encap:Ethernet  HWaddr F2:3C:91:98:E1:3B 
             ....
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:494 errors:0 dropped:0 overruns:0 frame:0
              TX packets:430 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:48804 (47.6 KiB)  TX bytes:356831 (348.4 KiB)
    
    eth0:1    Link encap:Ethernet  HWaddr F2:3C:91:98:E1:3B 
              inet addr:192.168.146.26  Bcast:192.168.255.255  Mask:255.255.128.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
    
    lo        Link encap:Local Loopback 
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:6 errors:0 dropped:0 overruns:0 frame:0
              TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:504 (504.0 b)  TX bytes:504 (504.0 b)
    
    But still I can't ping it on Nginx server :/
     
    • Like Like x 1
  18. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:23 AM
    1.91
    10.0.19
    Have you configured the Private iP also on the nginx sever
     
    • Informative Informative x 1
  19. RoldanLT

    RoldanLT Well-Known Member

    3,978
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    12:23 PM
    1.11
    10.2
    That! Fixed it :D
    Thanks a lot!
     
  20. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:23 AM
    1.91
    10.0.19
    Great stuff :D Glad ya got it working (y)
     
    • Winner Winner x 1