Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 152832

Summary: Can't connect to local MySQL server through socket ''/var/run/mysqld/mysqld.sock'' (2)
Product: Gentoo Linux Reporter: Greg McIntyre <gentoo>
Component: Current packagesAssignee: Gentoo Linux bug wranglers <bug-wranglers>
Status: RESOLVED DUPLICATE    
Severity: normal CC: etherealflaim
Priority: High    
Version: 2006.0   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Example C program which exposes bug, for me
MySQL configuration file

Description Greg McIntyre 2006-10-25 20:02:56 UTC
As of mysql-5.0.26, I receive the error message:

  Can't connect to local MySQL server through socket ''/var/run/mysqld/mysqld.sock'' (2)

When trying to connect in any mysql client, including the short example C program I wrote which I will attach.

I have gone through the checklists:
 - mysqld is running (duh)
 - unix socket file exists
 - unix socket file is accessible (permissions)
 - I can connect if I explicitly specify the unix socket path within mysql client programs
 - the mysql command line client connects fine
 - this only seems to effect programs linking against the mysql C client library including all mysql client language bindings installed
 - setting the socket path in the client section of my.cnf and restarting mysql can cause the normal mysql client to fail (it is reading the configuration) but programs linked against libmysqlclient still fail

Cause?

Look at the double quote in the error message and look at the output of this:

$ strings /usr/lib/mysql/libmysqlclient.so | grep sock
socket
setsockopt
sock
'/var/run/mysqld/mysqld.sock'  <---------------- !!!!!???
Can't create UNIX socket (%d)
Localhost via UNIX socket
Can't connect to local MySQL server through socket '%-.100s' (%d)
Can't create TCP/IP socket (%d)

I think that during compilation of mysql-5.0.26, that this extra set of quotes is being errornously compiled into libmysqlclient.so. This could be as a result of an error in the ebuild script but I cannot see any superfluous quotes in either /usr/portage/dev-db/mysql/mysql-5.0.26-r1.ebuild or in /usr/portage/eclass/mysql.eclass.

Suggested fix:

Diagnose why compilation process is causing extra quotes to the unix socket path and remove them. Could be ebuild or mysql compilation scripts.

Workaround?

I replaced the file /usr/lib/mysql/libmysqlclient.so.15.0.0 from a previous version of the mysql-5.0 series. Everything works for me now (provided I don't statically link because I didn't bother replacing .a/.la etc.)

emerge --info

Portage 2.1.1 (default-linux/x86/2006.0, gcc-4.1.1, glibc-2.4-r3, 2.6.17-gentoo-                                                                                          r4 i686)
=================================================================
System uname: 2.6.17-gentoo-r4 i686 Intel(R) Pentium(R) 4 CPU 3.00GHz
Gentoo Base System version 1.12.5
Last Sync: Tue, 24 Oct 2006 16:00:03 +0000
distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disable                                                                                          d]
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: 1.2.11-r1
dev-lang/python:     2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.13-r4
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r1
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=prescott -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shu                                                                                          tdown /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/shar                                                                                          e/X11/xkb /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dv                                                                                          ips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/con                                                                                          fig/ /usr/share/texmf/xdvi/"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-O2 -march=prescott -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks fixpackages metadata-transfer sandbox sfperms str                                                                                          ict"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/                                                                                          distributions/gentoo"
LINGUAS=""
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress                                                                                           --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/d                                                                                          istfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://muddy2/gentoo-portage"
USE="x86 X alsa apm bash-completion berkdb bitmap-fonts browserplugin bzip2 cdr                                                                                           cli cracklib crypt cups dlloader dri eds elibc_glibc emboss encode foomaticdb fo                                                                                          rtran gdbm gif gpm gstreamer gtk gtk2 imlib input_devices_evdev input_devices_ke                                                                                          yboard input_devices_mouse ipv6 isdnlog jpeg kernel_linux libg++ libwww mad mikm                                                                                          od mmx motif mp3 mpeg ncurses nls nptl nptlonly nsplugin ogg opengl oss pam pcre                                                                                           perl png pppd python qt3 qt4 quicktime readline reflection ruby samba sdl sessi                                                                                          on spell spl ssl tcpd tiff truetype truetype-fonts type1-fonts udev userland_GNU                                                                                           video_cards_fglrx video_cards_radeon vorbis win32codecs windowmaker xml xorg xv                                                                                           zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, PORTA                                                                                          GE_RSYNC_EXTRA_OPTS
Comment 1 Greg McIntyre 2006-10-25 20:06:47 UTC
Created attachment 100503 [details]
Example C program which exposes bug, for me

Short example largely copied out of mysql's help documents, which connects to the local mysql database using default settings for the unix socket path from libmysqlclient and fails:

  gcc -I/usr/include/mysql -g   -c -o mysqlplay.o mysqlplay.c
  gcc -lmysqlclient -L/usr/lib/mysql -g  mysqlplay.o   -o mysqlplay
  ./mysqlplay

Can't connect to local MySQL server through socket ''/var/run/mysqld/mysqld.sock'' (2)
MySQL server has gone away
Comment 2 Greg McIntyre 2006-10-25 20:11:44 UTC
Created attachment 100504 [details]
MySQL configuration file

In case it helps. I have barely edited it though and have made no changes re. socket paths since installing.
Comment 3 Kyle Lemons 2006-10-26 00:00:18 UTC
/usr/bin/mysqlbug:CONFIGURE_LINE="./configure  '--prefix=/usr' '--host=x86_64-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--libexecdir=/usr/sbin' '--sysconfdir=/etc/mysql' '--localstatedir=/var/lib/mysql' '--sharedstatedir=/usr/share/mysql' '--libdir=/usr/lib64/mysql' '--includedir=/usr/include/mysql' '--with-low-memory' '--with-client-ldflags=-lstdc++' '--enable-thread-safe-client' '--with-comment=Gentoo Linux mysql-5.0.26-r1' '--without-docs' '--without-big-tables' '--enable-local-infile' '--with-extra-charsets=all' '--with-mysqld-user=mysql' '--with-server' '--with-unix-socket-path='''/var/run/mysqld/mysqld.sock'''' '--without-libwrap' '--enable-shared' '--enable-static' '--without-debug' '--with-charset=utf8' '--with-collation=utf8_general_ci' '--without-embedded-privilege-control' '--without-embedded-server' '--with-bench' '--enable-assembler' '--with-extra-tools' '--with-innodb' '--without-readline' '--with-openssl' '--without-berkeley-db' '--with-geometry' '--without-ndbcluster' '--build=x86_64-pc-linux-gnu' 'build_alias=x86_64-pc-linux-gnu' 'host_alias=x86_64-pc-linux-gnu' 'CFLAGS=-march=k8 -O2 -pipe -DHAVE_ERRNO_AS_DEFINE=1 -fno-exceptions -fno-strict-aliasing' 'CXXFLAGS=-march=k8 -O2 -pipe -DHAVE_ERRNO_AS_DEFINE=1 -fno-exceptions -fno-strict-aliasing -felide-constructors -fno-rtti -fno-implicit-templates'"

Also note that in the line above, the --with-unix-socket-path='''/var/run/mysqld/mysqld.sock'''

but yet, in the mysql eclass,
myconf="${myconf} --with-unix-socket-path=/var/run/mysqld/mysqld.sock"

So, does that leave the problem as something in the ./configure?  To me, the difference between the arguments that the eclass generates and what mysqlbug thinks it was configured with is a major part of the problem
Comment 4 Jakub Moc (RETIRED) gentoo-dev 2006-10-26 00:33:50 UTC

*** This bug has been marked as a duplicate of 152455 ***