can't connect mysql

theplayer

Verified User
Joined
Jan 26, 2009
Messages
69
On my serverl severall sites are running for a year now. This day i add a new user with a new domain, no problem at this point.

I have uploaded a script and then i get this error:

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

I have search on this forum and found some informations but no go at the moment :-(

All running sites on the server works and everything seems to be ok with mysql etc... but this new site not.

Who can help me with this problem? os is Debian 5



this is in the /etc/mysql/my.cnf file:

Code:
[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
language        = /usr/share/mysql/english
skip-external-locking

hmmm /etc/my.cnf is allmost empty ? think this is not correct?
Code:
[mysqld]
local-infile=0
 
Last edited:
hmmm /etc/my.cnf is allmost empty ? think this is not correct?
Until recently DirectAdmin didn't supply my.cnf, but rather used all defaults. Recently they added those two lines. You can add anything else to my.cnf you want. See this article in the DirectAdmin knowledgebase.

Jeff
 
hmmm i have the problem en the solution, but then all other sites are broken :-(

If i change in the /etc/my.cnf file this:

Code:
[mysqld]
local-infile=0

to this:

Code:
[mysqld]
socket=/var/run/mysqld/mysqld.sock
local-infile=0

It works, but all my other site are broken. The other sites says:

Can't connect through socket '/tmp/mysql.sock'(2)

can anybody explain me what going on and how to fix this?
 
Last edited:
You just have two different mysqlclient libraries installed, probably one from CustomBuild and the other pulled in as dependency from some operating system repository package.

Leave the my.cnf file as it was, restart MySQL and create a symlink with "ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock".
 
Tillo,

it works!

BUT: As soon as i reboot the server it's the same error and must create the symlink again. How can i fix this?
 
Last edited:
Either use the @reboot function of cron in /etc/crontab or use any form of "rc.local" of your operating system to to recreate the link at reboot. You will need to use the "-f" switch to force the link if the socket is not yet created.
 
i have added the following to /etc/crontab:

Code:
@reboot ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock

But thats not working :-(
 
Last edited:
Like I said, use "ln -sf" instead of "ln -s". And you are also missing the user field.
Correct line would be:
Code:
@reboot root ln -sf /tmp/mysql.sock /var/run/mysqld/mysqld.sock
 
my bad.

is used now:

Code:
@reboot root ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock

and it works!

Should i change -s to - sf or?

btw thanks for your great help!
 
You would have needed the "-f" switch if the cron services started before the MySQL one, which apparently is not the case because it is working.

My pleasure.
 
Back
Top