Bug #11443 ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/
Submitted: 20 Jun 2005 4:15 Modified: 16 Sep 2005 23:47
Reporter: Arul Jose Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Installing Severity:S1 (Critical)
Version:standard-4.1.12-pc-linux-gnu-i686 OS:Linux (Linux)
Assigned to: Jim Winstead CPU Architecture:Any

[20 Jun 2005 4:15] Arul Jose
Description:
MYSQL INSTALLATION

[My writing is in bold, the terminal output is in plain]

i basically have the doubt where i should install. i have unzipped it in /home/aruljose/db/.
i have one more doubt : should client and server be downloaded separately and both be installed or server alone is enough?

i tried to install mysql, downloaded the following file.
mysql-standard-4.1.12-pc-linux-gnu-i686.tar

unzipped it to get the folder 'mysql-standard-4.1.12-pc-linux-gnu-i686'

Then i ran the executable - 'configure'

[aruljose@aruljose mysql-standard-4.1.12-pc-linux-gnu-i686]$ ./configure
NOTE: This is a MySQL binary distribution. It's ready to run, you don't
need to configure it!

To help you a bit, I am now going to create the needed MySQL databases
and start the MySQL server for you.  If you run into any trouble, please
consult the MySQL manual, that you can find in the Docs directory.

Installing all prepared tables
Fill help tables

To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system ## doubt: what could this right place be?

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands: ## doubt: where to issue?
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h aruljose password 'new-password'
See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com
Starting the mysqld server.  You can test that it is up and running
with the command:
./bin/mysqladmin version
[aruljose@aruljose mysql-standard-4.1.12-pc-linux-gnu-i686]$ Starting mysqld daemon with databases from /home/aruljose/db/mysql-standard-4.1.12-pc-linux-gnu-i686/data

Then i tried to invoke mysql. This is the message iam getting.

[aruljose@aruljose mysql-standard-4.1.12-pc-linux-gnu-i686]$ mysql
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

so i guess mysql has been installed since the command is detected. some setting needs to be done.

now how to proceed?

according to a manual which came along with the release,

" The basic commands you must execute to install and use a MySQL binary
distribution are:

     shell> groupadd mysql
     shell> useradd -g mysql mysql
     shell> cd /usr/local
     shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
     shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
     shell> cd mysql
     shell> scripts/mysql_install_db --user=mysql
     shell> chown -R root  .
     shell> chown -R mysql data
     shell> chgrp -R mysql .
     shell> bin/mysqld_safe --user=mysql & "

but the group add command is not working in the terminal. where to execute this command? should any classpath be set before executing these commands?

mysqlbug file
-----------------------

#!/bin/sh
# Create a bug report and mail it to the mysql mailing list
# Based on glibc bug reporting script.

echo "Finding system information for a MySQL bug report"

VERSION="4.1.12-standard"
COMPILATION_COMMENT="MySQL Community Edition - Standard (GPL)"
BUGmysql="mysql@lists.mysql.com"
# This is set by configure
COMP_ENV_INFO="CC='ccache gcc'  CFLAGS='-O2 -mcpu=pentiumpro'  CXX='ccache gcc'  CXXFLAGS='-O2 -mcpu=pentiumpro -felide-constructors'  LDFLAGS=''  ASFLAGS=''"
CONFIGURE_LINE="./configure '--prefix=/usr/local/mysql' '--localstatedir=/usr/local/mysql/data' '--libexecdir=/usr/local/mysql/bin' '--with-comment=MySQL Community Edition - Standard (GPL)' '--with-extra-charsets=complex' '--with-server-suffix=-standard' '--enable-thread-safe-client' '--enable-local-infile' '--enable-assembler' '--disable-shared' '--with-client-ldflags=-all-static' '--with-mysqld-ldflags=-all-static' '--with-readline' '--with-embedded-server' '--with-archive-storage-engine' '--with-innodb' 'CC=ccache gcc' 'CFLAGS=-O2 -mcpu=pentiumpro' 'CPPFLAGS=-DDEFAULT_THREAD_STACK=126976' 'CXXFLAGS=-O2 -mcpu=pentiumpro -felide-constructors' 'CXX=ccache gcc'"

LIBC_INFO=""
for pat in /lib/libc.* /lib/libc-* /usr/lib/libc.* /usr/lib/libc-*
do
    TMP=`ls -l $pat 2>/dev/null`
    if test $? = 0
    then
      LIBC_INFO="$LIBC_INFO
$TMP"
    fi
done

PATH=../client:$PATH:/bin:/usr/bin:/usr/local/bin
export PATH

BUGADDR=${1-$BUGmysql}
ENVIRONMENT=`uname -a`

: ${USER=${LOGNAME-`whoami`}}

COMMAND=`echo $0|sed 's%.*/\([^/]*\)%\1%'`

# Try to create a secure tmpfile
umask 077
TEMPDIR=/tmp/mysqlbug-$$
mkdir $TEMPDIR || (echo "can not create directory in /tmp, aborting"; exit 1;)
TEMP=${TEMPDIR}/mysqlbug

trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR; exit 1' 1 2 3 13 15
trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR' 0

# How to read the passwd database.
PASSWD="cat /etc/passwd"

if test -f /usr/lib/sendmail
then
  MAIL_AGENT="/usr/lib/sendmail -oi -t"
elif test -f /usr/sbin/sendmail
then
  MAIL_AGENT="/usr/sbin/sendmail -oi -t"
else
  MAIL_AGENT="rmail $BUGmysql"
fi

# Figure out how to echo a string without a trailing newline
N=`echo 'hi there\c'`
case "$N" in
  *c)	ECHON1='echo -n' ECHON2= ;;
  *)	ECHON1=echo ECHON2='\c' ;;
esac

# Find out the name of the originator of this PR.
if test -n "$NAME" 
then
  ORIGINATOR="$NAME"
elif test -f $HOME/.fullname
then
  ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
else
  # Must use temp file due to incompatibilities in quoting behavior
  # and to protect shell metacharacters in the expansion of $LOGNAME
  $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP
  ORIGINATOR="`cat $TEMP`"
  rm -f $TEMP
fi

if test -n "$ORGANIZATION"
then
  if test -f "$ORGANIZATION"
  then
    ORGANIZATION="`cat $ORGANIZATION`"
  fi
else
  if test -f $HOME/.organization
  then
    ORGANIZATION="`cat $HOME/.organization`"
  elif test -f $HOME/.signature
  then
    ORGANIZATION=`sed -e "s/^/  /" $HOME/.signature; echo ">"`
  fi
fi

PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `

which_1 ()
{
  for cmd
  do
    # Absolute path ?. 
    if expr "x$cmd" : "x/" > /dev/null
    then
      echo "$cmd"
      exit 0
    else
      for d in $PATH_DIRS
      do
	file="$d/$cmd"
	if test -x "$file" -a ! -d "$file"
	then
	  echo "$file"
	  exit 0
	fi
      done
    fi
  done
  exit 1
}

change_editor ()
{
  echo "You can change editor by setting the environment variable VISUAL."
  echo "If your shell is a bourne shell (sh) do"
  echo "VISUAL=your_editors_name; export VISUAL"
  echo "If your shell is a C shell (csh) do"
  echo "setenv VISUAL your_editors_name"
}

# If they don't have a preferred editor set, then use emacs
if test -z "$VISUAL"
then
  if test -z "$EDITOR"
  then
    EDIT=emacs
  else
    EDIT="$EDITOR"
  fi
else
  EDIT="$VISUAL"
fi

#which_1 $EDIT
used_editor=`which_1 $EDIT`

echo "test -x $used_editor"
if test -x "$used_editor"
then
  echo "Using editor $used_editor";
  change_editor
  sleep 2
else
  echo "Could not find a text editor. (tried $EDIT)"
  change_editor
  exit 1
fi

# Find out some information.
SYSTEM=`( test -f /bin/uname  && /bin/uname -a ) || \
        ( test -f /usr/bin/uname  && /usr/bin/uname -a ) || echo ""`
ARCH=`test -f /bin/arch  && /bin/arch`
MACHINE=`test -f /bin/machine  && /bin/machine`
FILE_PATHS=

for cmd in perl make gmake gcc cc
do
  file=`which_1 $cmd`
  if test $? = 0
  then
    if test $cmd = "gcc"
    then
      GCC_INFO=`$file -v 2>&1`
    elif test $cmd = "perl"
    then
      PERL_INFO=`$file -v | grep -i version 2>&1`
    fi
    FILE_PATHS="$FILE_PATHS $file"
  fi
done

admin=`which_1 mysqladmin`
MYSQL_SERVER=
if test -x "$admin"
then
  MYSQL_SERVER=`$admin version 2> /dev/null`
  if test "$?" = "1"
  then
    MYSQL_SERVER=""
  fi
fi

SUBJECT_C="[50 character or so descriptive subject here (for reference)]"
ORGANIZATION_C='<organization of PR author (multiple lines)>'
LICENCE_C='[none | licence | email support | extended email support ]'
SYNOPSIS_C='<synopsis of the problem (one line)>'
SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
PRIORITY_C='<[ low | medium | high ] (one line)>'
CLASS_C='<[ sw-bug | doc-bug | change-request | support ] (one line)>'
RELEASE_C='<release number or tag (one line)>'
ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
DESCRIPTION_C='<precise description of the problem (multiple lines)>'
HOW_TO_REPEAT_C='<code/input/activities to reproduce the problem (multiple lines)>'
FIX_C='<how to correct or work around the problem, if known (multiple lines)>'

cat > $TEMP <<EOF
SEND-PR: -*- send-pr -*-
SEND-PR: Lines starting with \`SEND-PR' will be removed automatically, as
SEND-PR: will all comments (text enclosed in \`<' and \`>').
SEND-PR:
From: ${USER}
To: ${BUGADDR}
Subject: $SUBJECT_C

>Description:
	$DESCRIPTION_C
>How-To-Repeat:
	$HOW_TO_REPEAT_C
>Fix:
	$FIX_C

>Submitter-Id:	<submitter ID>
>Originator:	${ORIGINATOR}
>Organization:
${ORGANIZATION- $ORGANIZATION_C}
>MySQL support: $LICENCE_C
>Synopsis:	$SYNOPSIS_C
>Severity:	$SEVERITY_C
>Priority:	$PRIORITY_C
>Category:	mysql
>Class:		$CLASS_C
>Release:	mysql-${VERSION} ($COMPILATION_COMMENT)
`test -n "$MYSQL_SERVER" && echo ">Server: $MYSQL_SERVER"`
>C compiler:    2.95.3
>C++ compiler:  2.95.3
>Environment:
	$ENVIRONMENT_C
`test -n "$SYSTEM"  && echo "System: $SYSTEM"`
`test -n "$ARCH"  && echo "Architecture: $ARCH"`
`test -n "$MACHINE"  && echo "Machine: $MACHINE"`
`test -n "$FILE_PATHS"  && echo "Some paths: $FILE_PATHS"`
`test -n "$GCC_INFO"  && echo "GCC: $GCC_INFO"`
`test -n "$COMP_ENV_INFO"  && echo "Compilation info: $COMP_ENV_INFO"`
`test -n "$LIBC_INFO"  && echo "LIBC: $LIBC_INFO"`
`test -n "$CONFIGURE_LINE"  && echo "Configure command: $CONFIGURE_LINE"`
`test -n "$PERL_INFO"  && echo "Perl: $PERL_INFO"`
EOF

chmod u+w $TEMP
cp $TEMP $TEMP.x

eval $EDIT $TEMP

if cmp -s $TEMP $TEMP.x
then
  echo "File not changed, no bug report submitted."
  mv -f $TEMP /tmp/failed-mysql-bugreport
  echo "The raw bug report exists in /tmp/failed-mysql-bugreport"
  echo "If you use this remember that the first lines of the report are now a lie.."
  exit 1
fi

#
#       Check the enumeration fields

# This is a "sed-subroutine" with one keyword parameter
# (with workaround for Sun sed bug)
#
SED_CMD='
/$PATTERN/{
s|||
s|<.*>||
s|^[ 	]*||
s|[ 	]*$||
p
q
}'

while :; do
  CNT=0

  #
  # 1) Severity
  #
  PATTERN=">Severity:"
  SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
  case "$SEVERITY" in
    ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
    *)  echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
  esac
  #
  # 2) Priority
  #
  PATTERN=">Priority:"
  PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
  case "$PRIORITY" in
    ""|low|medium|high) CNT=`expr $CNT + 1` ;;
    *)  echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
  esac
  #
  # 3) Class
  #
  PATTERN=">Class:"
  CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
  case "$CLASS" in
    ""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;;
    *)  echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
  esac

  #
  # 4) Synopsis
  #
  VALUE=`grep "^>Synopsis:" $TEMP | sed 's/>Synopsis:[ 	]*//'`
  case "$VALUE" in
    "$SYNOPSIS_C")  echo "$COMMAND: \`$VALUE' is not a valid value for \`Synopsis'." ;;
    *) CNT=`expr $CNT + 1` 
  esac

  test $CNT -lt 4  &&
    echo "Errors were found with the problem report."

  #       Check if subject of mail was changed, if not, use Synopsis field
  #
  subject=`grep "^Subject" $TEMP| sed 's/^Subject:[ 	]*//'`
  if [ X"$subject" = X"$SUBJECT_C" -o X"$subject" = X"$SYNOPSIS_C" ]; then
    subject=`grep Synopsis $TEMP | sed 's/>Synopsis:[     ]*//'`
    sed "s/^Subject:[ 	]*.*/Subject: $subject/" $TEMP > $TEMP.tmp
    mv -f $TEMP.tmp $TEMP
  fi

  while :; do
    $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
    read input
    case "$input" in
      a*)
	echo "$COMMAND: problem report saved in $HOME/dead.mysqlbug."
	cat $TEMP >> $HOME/dead.mysqlbug
        xs=1; exit
        ;;
      e*)
        eval $EDIT $TEMP
        continue 2
        ;;
      s*)
        break 2
        ;;
    esac
  done
done
#
#       Remove comments and send the problem report
#       (we have to use patterns, where the comment contains regex chars)
#
# /^>Originator:/s;$ORIGINATOR;;
sed  -e "
/^SEND-PR:/d
/^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
/^>Confidential:/s;<.*>;;
/^>Synopsis:/s;$SYNOPSIS_C;;
/^>Severity:/s;<.*>;;
/^>Priority:/s;<.*>;;
/^>Class:/s;<.*>;;
/^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
/^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
/^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
/^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
/^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
" $TEMP > $TEMP.x

if $MAIL_AGENT < $TEMP.x
then
  echo "$COMMAND: problem report sent"
  xs=0; exit
else
  echo "$COMMAND: mysterious mail failure, report not sent."
  echo "$COMMAND: problem report saved in $HOME/dead.mysqlbug."
  cat $TEMP >> $HOME/dead.mysqlbug
fi

exit 0

How to repeat:
i dont get what you are asking for

Suggested fix:
dont know
[21 Jun 2005 10:36] Aleksey Kishkin
default place for unix socket for binaries that had been built in MySQL AB is /tmp/mysql.sock. 
If you see error that mysql cannot found /var/lib/mysql/mysql.sock it usually means you have another mysql installation on your computer (for instance - from linux distributive).

Could you please:

 - check if you have /etc/my.cnf with creation time elder than you new mysql installation?
- check if you have another mysql server (or client on your computer) - for example (if you have rpm-based linux) 
  rpm -qi MySQL-client
- check what exactly mysql did you run:
$> which mysql
[25 Jun 2005 5:10] Paul McArdle
I did rpm -i -force Mysq* to upgrade mysql4.x . red hat 9
got same problem.
use '-S/tmp/mysql.sock' in command line to get all commands working.
all apps show 5x beta, client & server.
am newby to red hat & mysql.
mysql-administrator connects to /tmp/mysql.sock fine, didnt show users for a while complained about a view, now fine.
others apps including, msqladmin & plain mysql need -S parm
my.cnf says /tmp/mysql.sock
[21 Jul 2005 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[16 Sep 2005 22:25] MySQL Verification Team
Verified on Fedora Core 4:

[miguel@hegel ~]$ uname -a
Linux hegel 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 athlon i386 GNU/Linux

Package: mysql-standard-4.1.14-pc-linux-gnu-i686.tar.gz

[miguel@hegel mysql-standard-4.1.14-pc-linux-gnu-i686]$ ./configure 
NOTE: This is a MySQL binary distribution. It's ready to run, you don't
need to configure it!

To help you a bit, I am now going to create the needed MySQL databases
and start the MySQL server for you.  If you run into any trouble, please
consult the MySQL manual, that you can find in the Docs directory.

Installing all prepared tables
Fill help tables

<cut>

[miguel@hegel mysql-standard-4.1.14-pc-linux-gnu-i686]$ Starting mysqld daemon with databases from /home/miguel/mysql-standard-4.1.14-pc-linux-gnu-i686/data

From another shell:

[miguel@hegel ~]$ mysql -uroot
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

[miguel@hegel ~]$ mysql -uroot --socket=/tmp/mysql.sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.14-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
[16 Sep 2005 23:47] Jim Winstead
When you run 'mysql', you are almost certainly running a version of the mysql client installed via a Red Hat RPM, which will be compiled with a different socket location. The solution is either to install our RPMs to install the updated client and server, specify the path to the socket file on the command line, or use the client program included in your installation.