Can't connect to local MySQL server through socket

I am very new to sing MySQL and RT so please bear with me. I can connect to
the database (RT and others) using mysqladmin, however, I cannot connect
using the rtadmin utility. The following is the error message I get. Any
help would be very appreciated.
Thanks
Bob

Mysql->connect(database=rt;host=localhost) failed: Can’t connect to local
MySQL
server through socket ‘/var/lib/mysql/mysql.sock’ (111) at
/opt/rt/lib/rt/databa
se.pm line 24
[connectdb] Database connect failed: Can’t connect to local MySQL server
through
socket ‘/var/lib/mysql/mysql.sock’ (111)
Compilation failed in require at /opt/rt/lib/rt/database/manipulate.pm line
5.
Compilation failed in require at /opt/rt/bin/rtmux.pl line 28.
[root@support1 bin]# ./rtadmin queue -create Test
Mysql->connect(database=rt;host=localhost) failed: Can’t connect to local
MySQL
server through socket ‘/var/lib/mysql/mysql.sock’ (111) at
/opt/rt/lib/rt/databa
se.pm line 24
[connectdb] Database connect failed: Can’t connect to local MySQL server
through
socket ‘/var/lib/mysql/mysql.sock’ (111)
Compilation failed in require at /opt/rt/lib/rt/database/admin.pm line 8.
Compilation failed in require at /opt/rt/bin/rtmux.pl line 40.
[root@support1 bin]#
[root@support1 bin]#

Hi,

On Mit, 27 Dez 2000, Robert McDuffee sent incredible lines:
[…]

Mysql->connect(database=rt;host=localhost) failed: Can’t connect to local
MySQL
server through socket ‘/var/lib/mysql/mysql.sock’ (111) at
/opt/rt/lib/rt/databa
se.pm line 24
[…]

Look’s like MySQL database is not running. Are you sure that you’ve
starting the db server?

… may the Tux be with you! =Thomas=
Thomas Bendler \:// ml@bendler-net.de
Billwiese 22 (o -) http://www.bendler-net.de/
21033 Hamburg —ooO-(_)-Ooo— tel.: 0 177 - 277 37 61
Germany Linux, enjoy the ride …!

I setup MySQL 3.23 from an rpm, and created a /etc/my.cnf file with the
parameter for the mysql.sock file
socket=/var/lib/mysql/mysql.sock

I am able to connect with mysqladmin, as described in the mysql
documentation,
http://www.mysql.com/doc/C/a/Can_not_connect_to_server.html
but rt is still trying to connect through /tmp/mysql.sock.

Here is the output:

[root@redhat03 bin]# ./rtadmin queue -create admin
Mysql->connect(database=rt;host=localhost) failed: Can’t connect to local
MySQL server through socket ‘/tmp/mysql.sock’ (111) at
/usr/local/rt/lib/rt/database.pm line 24
[connectdb] Database connect failed: Can’t connect to local MySQL server
through socket ‘/tmp/mysql.sock’ (111)
[root@redhat03 bin]#

Any idea why?

/------------------------------------------
Scott McClelland, CNE, MCP
Network Administrator
Vortex Data Systems
http://www.vortexdata.com
--------------------------------------------
/

Thank you, that worked. I modified the /etc/my.cnf as follows, and
everything works fine.

[root@redhat03 admin]# cat /etc/my.cnf
[client]
port=3306
socket=/tmp/mysql.sock

[mysqld]
port=3306
socket=/tmp/mysql.sock
You have new mail in /var/spool/mail/root
[root@redhat03 admin]#

/------------------------------------------
Scott McClelland, CNE, MCP
Network Administrator
Vortex Data Systems
http://www.vortexdata.com
--------------------------------------------
/

If you can’t find mysql.sock anywhere, then mysqld is probably not running.
Try running
shell> mysqladmin version
or just do a find, like this:
shell> find / -name mysql.sock

What I had to do was change /etc/my.cnf to point to the actual location of
the mysql.sock file (which gets created when mysqld starts, and goes away
when the daemon stops), rather than /var/lib/mysql/mysql.sock

The /etc/my.cnf file is explained here:
http://www.mysql.com/doc/O/p/Option_files.html

Here is the new contents of my /etc/my.cnf file:

[client]
port=3306
socket=/tmp/mysql.sock

[mysqld]
port=3306
socket=/tmp/mysql.sock
There is some good documentation at mysql.com, but you have to search for
the specific problem.
http://www.mysql.com/doc/P/o/Post-installation.html

I didn’t remember if I kept the RPM, or reinstalled from source (I tried so
many things). It is an RPM after all:

rpm -q MySQL
MySQL-3.23.36-1

/------------------------------------------
Scott McClelland, CNE, MCP
Network Administrator
Vortex Data Systems
http://www.vortexdata.com
--------------------------------------------
/

when I do mysqladmin version, it is also complaining about can not
connect to mysql server and can not find /tmp/mysql.sock
Try
shell> mysqladmin --socket=/tmp/mysql.sock version
(where /tmp/mysql.sock is the actual location of the mysql.sock file)

nothing return after do the find / -name mysql.sock
That’s probably because the mysqld daemon is not running

when I bin/safe_mysqld &
I got “starting mysql daemon database with /usr/local/mysql/data
11:50:33 mysql ended”

in /etc/my.cnf file
it already has the port and socket path in there.
I would try starting mysqld without the /etc/my.cnf file (rename it
temporarily)

Is it possible my mysql installation missing the mysql.sock file?
No, the mysql.sock file is created when mysqld starts.

It appears that mysqld is not starting. Try
shell> ps -ax | grep mysqld
to see if it is running.

Rename or move the /etc/my.cnf file, then, run:
shell> bin/safe_mysqld &
and find out where the mysql.sock file is (with find), and modify the my.cnf
file to match the location of the actual mysql.sock file.

There is a very good page on testing mysql connections here:
http://www.mysql.com/doc/C/a/Can_not_connect_to_server.html

O.K. Cassie, let’s start from the begining. I know this is not a MySQL
list, but the information should be helpful to people wanting to get RT
running. It took me a long time to figure out all the steps to install RT
(perl MySQL, etc.), but it was worth it, so stick with it. I’m not sure how
much time I will have to help you, as I can get busy.

Answer a few questions:

What distribution of Linux (cat /etc/issue)

What version of MySQL, and what install method - rpm, binary, source (rpm -q
MySQL)

Did you install MySQL as root?

Are you trying to run safe_mysqld as root?

/------------------------------------------
Scott McClelland, CNE, MCP
Network Administrator
Vortex Data Systems
http://www.vortexdata.com
--------------------------------------------
/

Here is Cassie’s reply. Anybody have any idea what to try next? Maybe
reinstall MySQL from rpms or srpms?

A reinstall should also stop any mysql servers during the installation. You
could also try killall mysqld, (or reboot the server). It does appear to be
running, if you were able to attach to it.

/------------------------------------------
Scott McClelland, CNE, MCP
Network Administrator
Vortex Data Systems
http://www.vortexdata.com
--------------------------------------------
/

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I managed to get it running by compiling from source.

I had to set up the mysql user and group (since by default MySQL will
not run as root), and then give that as an option during compile
(–with-mysqld-user=mysql). Once I did this, I was able to su up to the
mysql user and start the daemon.

I’ve come in late on this thread, but ISTR that http://www.mysql.com/
kept a fairly complete set of documentation online, including
step-by-steps to building, installing and first-time running of the
database.

HTH,


Ed Vazquez
Senior Security Engineer
Inflow, Inc. (http://www.inflow.com/home.asp)
303.942.3211

These days, if I owned the M$ division that built Lookout and
SexChange, I’d trade it for a dog, and then I’d shoot the dog.

  • –Mike Andrews in the Monastery.On Thu, 31 May 2001, Scott McClelland wrote:

Date: Thu, 31 May 2001 15:50:52 -0700
From: Scott McClelland smcclell@vortexdata.com
To: “‘rt-users@lists.fsck.com’” rt-users@lists.fsck.com
Cc: “‘CChang@thesupply.com’” CChang@thesupply.com
Subject: [rt-users] RE: Can’t connect to local MySQL server through socket

Here is Cassie’s reply. Anybody have any idea what to try next? Maybe
reinstall MySQL from rpms or srpms?

A reinstall should also stop any mysql servers during the installation. You
could also try killall mysqld, (or reboot the server). It does appear to be
running, if you were able to attach to it.

/------------------------------------------
Scott McClelland, CNE, MCP
Network Administrator
Vortex Data Systems
http://www.vortexdata.com
--------------------------------------------
/

-----Original Message-----
From: Cassie Chang [mailto:CChang@thesupply.com]
Sent: Thursday, May 31, 2001 3:27 PM
To: 'Scott McClelland’
Subject: RE: Can’t connect to local MySQL server through socket

Scott,

What distribution of Linux (cat /etc/issue)

  • Redhat Linux 7.1
    Kernel 2.4 2-2 on an i686

What version of MySQL, and what install method - rpm, binary,
source (rpm -q
MySQL)

  • 3.23.38 binary

Did you install MySQL as root?

  • yes
    Are you trying to run safe_mysqld as root?
  • yes

I ran mysqladmin -h budlight(my host name) --port=3306 variables
(as stated in 22.3 mysql online doc), it tells me my socket is
/tmp/mysql.sock

that means I already have a mysql server running on that port 3306
but I can not see the process in ps, I can not find mysql.sock file
I do not know how to either remove that server on that port or ?

Cassie

/------------------------------------------
Scott McClelland, CNE, MCP
Network Administrator
Vortex Data Systems
http://www.vortexdata.com
--------------------------------------------
/

-----Original Message-----
From: Cassie Chang [mailto:CChang@thesupply.com]
Sent: Thursday, May 31, 2001 2:20 PM
To: 'Scott McClelland’
Subject: RE: Can’t connect to local MySQL server through socket

Scott,

I rename my.cnf to my.cnf1
I do ps -ax | grep mysql - no mysql process running

I bin/safe_mysqld &
-it said mysql ended

I check the hostname.err
error message is:
“Can’t start server: Bind on TCP/IP port; Address already in use
Do you have another server running on port 3306”

? Thanks
Cassie


rt-users mailing list
rt-users@lists.fsck.com
http://lists.fsck.com/mailman/listinfo/rt-users

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (OpenBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE7Fs3IsgiUrZLjn0MRAkY5AJ9/Sqxaye1F+SrrkYtON/ru3HO5IQCgjr8K
XBy39LtRQkVdm4f3+Fu67kQ=
=mVc2
-----END PGP SIGNATURE-----

Hi,
My apache show me error while I tried to browse to RT server.

DBI connect(‘dbname=rt3;host=localhost’,‘rt_user’,…) failed: Can’t
connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
(13) at /usr/local/lib/perl5/site_perl/5.8.0/DBIx/SearchBuilder/Handle.pm
line 132

[error] Connect Failed Can’t connect to local MySQL server through socket
’/var/lib/mysql/mysql.sock’ (13)
at /opt/rt3/lib/RT.pm line 149

I tried the solution by searching from the archives but none of these can help.
Below is the software installed for the server.

RT-3.0.6
mysql4.0.15a
perl 5.8.0
apache 1.3.27

Please Help,
Regards,
hwahing

Hi I found the solution for this problem, It was the directory permission
set to 700
Now I got another problem. I can’t loging into from web UI.

At 07:58 PM 10/1/2003 +0800, Ling Hwa Hing wrote:

Hi,
My apache show me error while I tried to browse to RT server.

DBI connect(‘dbname=rt3;host=localhost’,‘rt_user’,…) failed: Can’t
connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
(13) at /usr/local/lib/perl5/site_perl/5.8.0/DBIx/SearchBuilder/Handle.pm
line 132

[error] Connect Failed Can’t connect to local MySQL server through socket
’/var/lib/mysql/mysql.sock’ (13)
at /opt/rt3/lib/RT.pm line 149

I tried the solution by searching from the archives but none of these can
help.
Below is the software installed for the server.

RT-3.0.6
mysql4.0.15a
perl 5.8.0
apache 1.3.27

Please Help,
Regards,
hwahing

Ling Hwa Hing
Internet Data Center
Tel: 03-2938 6688
Fax: 03-2282 8072