mysql5 error

kompi

Verified User
Joined
Jul 11, 2008
Messages
14
I have mysql5 with DA from custombuild.
Today my mysql is broken.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I read to make a link to /tmp/mysql.sock -> /var/run/mysqld/mysqld.sock etc.

On my server there is no such file anywhere mysql.sock

It's my all config file from mysql (and may they not? )
#/etc/my.cnf
[mysqld]
local-infile=0

How can I fix this?
I have a lot on the server database and I do not want to lose this data.
 
Debian 4

# whereis mysql
mysql: /usr/local/bin/mysql /usr/local/mysql

/etc/mysql - there is no such directory
 
Then set mysql sock location in php.ini or my.cnf to be the same.
 
ok, but where is the mysql.sock file?
I search all files and nothing result.
 
Usually the path is "/var/run/mysql/mysqld.sock".
There is no default path or socket name, every distribution chose theirs... but you can override that in "/etc/my.cnf" (or, again, "/etc/mysql/my.cnf" depending on your distribution) with "socket = /path/to/mysql.sock" under "[mysqld]".
 
I do not have the file mysql.sock on my serwer.

with phpinfo()

MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 5.0.67
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_INCLUDE -I/usr/local/mysql/include
MYSQL_LIBS -L/usr/local/mysql/lib -lmysqlclient
 
Search for "mysqld.sock" instead of "mysql.sock".

Anyway, phpinfo() will print the path PHP is looking for (that can be changed in php.ini). To see what socket path has been compiled into MySQL run "mysqld --verbose --help |grep ^socket"
 
already looking for all files *. sock and I did not find any.

this can be somehow generate a new without losing the data in the database?
 
The socket is created by mysqld when running. If it isn't there, then mysqld is not running. Check your logs. And run "mysqld --verbose --help |grep ^socket", so you know where to look exactly.
 
b217:/# /etc/init.d/mysqld start
Starting mysqld: [ OK ]
b217:/# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
b217:/# /etc/init.d/mysqld --verbose --help |grep ^socket
b217:/# (nothing)
 
When I tell you to run "mysqld --verbose --help |grep ^socket" I mean that, not "/etc/init.d/mysqld --verbose --help |grep ^socket" :)
If it can't find mysqld in your PATH, it's probably "/usr/local/mysql/bin/mysqld" or "/usr/local/bin/mysqld".

Also, to check if mysqld is really running run "ps auxw |grep mysqld".
 
b217:/# /usr/local/mysql-5.0.67-linux-i686/bin/mysqld
090325 0:37:27 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
090325 0:37:27 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
090325 0:37:27 [ERROR] Can't find messagefile '/usr/local/mysql/share/mysql/english/errmsg.sys'
090325 0:37:27 [ERROR] Aborting
 
Last edited:
Ok... let's try again... run "/usr/local/mysql-5.0.67-linux-i686/bin/mysqld --verbose --help |grep ^socket" :P
 
b217:#/usr/local/mysql-5.0.67-linux-i686/bin/mysqld --verbose --help |grep ^socket
090325 1:00:44 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
090325 1:00:44 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
socket /tmp/mysql.sock
 
As you can see, the socket should be "/tmp/mysql.sock". If it isn't there, it's because mysql is not starting right. Restart it by running "/etc/init.d/mysql restart" then check the last lines of the errors log file by running "tail -n 100 /usr/local/mysql/data/*.err".
 
/etc/init.d/mysqld restart
Starting mysqld: [ OK ]

with proces - nothing running mysql
with error log - nothing ebaout mysql (no errors)
 
Then something is really wrong :)
If you are using custombuild (which I think you do), recompile and reinstall it by running "cd /usr/local/directadmin/custombuild; ./build mysql d".
 
Back
Top