MySQL/notes

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< MySQL
Revision as of 01:01, 4 January 2008 by Woozle (talk | contribs) (→‎Overview: Address Binding)
Jump to navigation Jump to search

Navigation

computing: software: databases: engines: MySQL: notes

Overview

This page is for any loose notes on MySQL for which there isn't yet a specific page.

Address Binding

If you get this message on attempting to connect to a remote mysql server (named "rizzo" in this case):

ERROR 2003 (HY000): Can't connect to MySQL server on 'rizzo' (111)

...and "telnet rizzo 3306" returns this (where rizzo is at 192.168.0.103):

Trying 192.168.0.103...
telnet: Unable to connect to remote host: Connection refused

...then the problem may be that mysql is only "listening" on its loopback interface. Look in the my.cnf file for:

bind-address		= 127.0.0.1

...and change it to:

bind-address	= 192.168.0.103

...using your mysql server's actual IP address instead of the one given.

It's not clear if there's any address-nonspecific way of doing this so that (e.g.) if rizzo were to be assigned a different IP address later on, my.cnf would not need to be changed.

MySQL on a DNS server

Some observations on 2007-09-21, from the owner/operator of a small web hosting provider. These only apply if:

  • the web sites are on a different machine from the MySQL server
  • the web site machine is connected to the MySQL server directly (typically via crossover cable), rather than going through the LAN

What happened, and the solution (in brief):

Tonight, my cluster bit the dust. Every time we would restart MySQL, we would immediately be deluged with huge amounts of "unauthenticated users" hitting up the DB server. Thanks to the good folks in #MySQL on EFNet IRC, they turned me onto http://hackmysql.com/dns
For /etc/my.cnf
After [mysqld]
ADD this, on its own line: skip-name-resolve
---------------------
If you're running your DNS on the same machine as your DB server, make SURE you add the three following lines to /etc/resolv.conf:
nameserver 127.0.0.1
nameserver 192.168.0.10
nameserver 192.168.0.20
Modifying the two 192.168.x.x ranges to be the IP's of your internal private network.
At one point, my DB server was deluged with over 2300 requests that were trying to do reverse DNS on 192.168.0.10 (which is the web server, .20 is the DB server). Since the entire 192.168.X.X block is set aside for internal private networks, chances are that you will NOT have those resolving into hostnames. The problem was that my DB server was trying to resolve all 2300 requests into a hostname before it allowed DB queries to go through.
You'll have to restart (or shut down/kill off all MySQL processes, remove mysql.sock and your pid file) and then start MySQL up again.
I hope this saves someone the two hours of headache I've just gone through getting this sorted.

Full post is here.