Bug in mysqld option "--bind-address"
am 21.11.2002 12:04:52 von Arnauld Michelizza>Description:
Mysqld '--bind-address' doesn't work with host names.
My server has several IP and I want to bind on one of them :
--bind-addresse=altserver
But it doesn't work : mysqld always bind on the IP which
is given by `hostname -i`.
>How-To-Repeat:
1/ First, you have to configure your hostname and your main
network interface :
% hostname mainserver
% ifconfig eth0 *put*your*real*ip*there* up
2/ Configure an ip aliase :
% ifconfig eth0:0 10.0.0.1 up
3/ Configure your /etc/hosts and test it :
% cat >> /etc/hosts
*put*your*real*ip*there* mainserver
10.0.0.1 altserver
^D
% ping -c1 altserver && echo ok || echo bad configuration
4/ Run your mysql server so it binds on the alternate IP :
% safe_mysqld --bind-addresse=altserver
5/ Then, you can easily verify that mysqld listen on the main IP
and not on 10.0.0.1 one :
% netstat -tln | grep 3306
If you have no network interface, you could try this :
1/ Configure an alternate hostname and test it :
% cat >> /etc/hosts
127.0.0.2 altserver
^D
% ping -c1 altserver && echo ok || echo bad configuration
2/ Run your mysql server so it binds on the alternate IP :
% safe_mysqld --bind-addresse=altserver
5/ Then, you can easily verify that mysqld is not listening on
127.0.0.2 :
% netstat -tln | grep 3306
>Fix:
By quickly examining the code, it seems that there is an
intervertion in the 'if...else...' clause :
--- mysql-3.23.53/sql/mysqld.cc Thu Oct 10 12:17:28 2002
+++ mysql-3.23.53-patch/sql/mysqld.cc Tue Nov 19 12:19:30 2002
@@ -3831,9 +3831,8 @@
else
{
struct hostent *ent;
+
if (!optarg || !optarg[0])
- ent=gethostbyname(optarg);
- else
{
char myhostname[255];
if (gethostname(myhostname,sizeof(myhostname)) < 0)
@@ -3843,6 +3842,9 @@
}
ent=gethostbyname(myhostname);
}
+ else
+ ent=gethostbyname(optarg);
+
if (!ent)
{
sql_perror("Can't start server: cannot resolve hostname!");
>Submitter-Id:
>Originator:
>Organization:
>MySQL support: none
>Synopsis: Bug in mysqld option '--bind-address'
>Severity: non-critical
>Priority: high
>Category: mysql
>Class: sw-bug
>Release: mysql-3.23.53 (Source distribution)
>Environment:
System: Linux devsi 2.2.20 #1 Sat Apr 20 11:45:28 EST 2002 i686 unknown
Architecture: i686
Some paths: /usr/bin/perl /usr/bin/make /usr/bin/gcc /usr/bin/cc
GCC: Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)
Compilation info: CC='gcc' CFLAGS='-O3 -mpentiumpro' CXX='gcc'
CXXFLAGS='-O3 -mpentiumpro -felide-
constructors -fno-exceptions -fno-rtti' LDFLAGS=''
LIBC:
lrwxrwxrwx 1 root root 13 Oct 10 15:57 /lib/libc.so.6 ->
libc-2.2.5.so
-rwxr-xr-x 1 root root 1153784 Apr 28 2002 /lib/libc-2.2.5.so
-rw-r--r-- 1 root root 2390922 Apr 28 2002 /usr/lib/libc.a
-rw-r--r-- 1 root root 178 Apr 28 2002 /usr/lib/libc.so
Configure command: ./configure --prefix=/home/mysql --with-gnu-ld --enable-assembler --with-mysqld-user=mysql --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --disable-shared --with-extra-charset=all --with-innodb --without-debug 'CFLAGS=-O3 -mpentiumpro' 'CXXFLAGS=-O3 -mpentiumpro-felide-constructors -fno-exceptions -fno-rtti' CXX=gcc
------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail bugs-thread13058@lists.mysql.com
To unsubscribe, e-mail