Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2005
    Posts
    56

    trying to connect to mysql remotely

    I've been trying to connect to a remote mysql server..

    I have made sure skip-networking is commented out in the my.cnf

    I have the iptables rule set correctly (I copy and pasted a rule that
    the webhost is/was using for mysql backups).
    -A newconnection -s x.x.x.x -p tcp -m tcp --dport 3306 -j ACCEPT
    It is being called like so:
    /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql
    --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306
    --socket=/var/run/mysqld/mysqld.sock
    Here is the output when trying to connect remotely using telnet from
    3 different allowed locations(local shell, remote shell and another
    remote shell):
    [[email protected] ~]$ telnet www.remote.com 3306
    Trying xx.xx.xx.xx...
    Connected to www.remote.com (xx.xx.xx.xx).
    Escape character is '^]'.
    Connection closed by foreign host.
    Here is the output when trying to connect locally using telnet (this
    is assuming I've setup a user with the proper permissions):
    remote:~# telnet 127.0.0.1 3306
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    7
    4.0.24_Debian-10sarge2ÉYYcAY}*UOi,Connection closed by foreign host.
    Here is the output of netstat after trying to connect remotely using PHP:
    remote:~# netstat -an | grep 3306
    tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
    tcp 0 0 local_ip:3306 remote_ip:13238 TIME_WAIT
    Here is the error on the PHP side I will get:
    Lost connection to MySQL server during query
    I also granted permissions like so:
    grant SELECT, DELETE, UPDATE on remote.* to 'remote'@'vpn.local.com'
    identified by 'password'
    Here is the contents of /etc/mysql/my.cnf minus the comments:
    [client]
    port = 3306
    socket = /var/run/mysqld/mysqld.sock

    [mysqld_safe]
    socket = /var/run/mysqld/mysqld.sock
    nice = -5

    [mysqld]
    user = mysql
    pid-file = /var/run/mysqld/mysqld.pid
    socket = /var/run/mysqld/mysqld.sock
    port = 3306
    basedir = /usr
    datadir = /var/lib/mysql
    tmpdir = /tmp
    language = /usr/share/mysql/english
    skip-external-locking
    key_buffer = 16M
    max_allowed_packet = 16M
    thread_stack = 128K
    query_cache_limit = 1048576
    query_cache_size = 26214400
    query_cache_type = 1
    skip-innodb

    [mysqldump]
    quick
    quote-names
    max_allowed_packet = 16M

    [mysql]

    [isamchk]
    key_buffer = 16M
    I've scoured the web.. and I'm at a loss. I'm not a network guru but
    this seems like it is more difficult then it needs to be...

    The server does have a heartbeat channel setup using HA Linux but I
    don't know if that would affect this at all.

  2. #2
    Join Date
    Jul 2005
    Posts
    56
    Resolved:
    I needed to add a line to /etc/hosts.allow.

    example:
    mysqld: 123.123.123.
    The reason for this is because the server has tcp_wrappers which is not as common anymore due to firewalls.
    Last edited by opera.mp3; 10-18-2006 at 10:07 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •