The numbers in parentheses are almost certainly system error numbers, normally reported via errno
, the definitions for which are found via #include <errno.h>
though on Solaris the numbers are usually in /usr/include/sys/errno.h
(but can be in other places, especially on Linux and Mac OS X). You could write a simple program to see the 3 errors.
#include <stdio.h>
#include <string.h>
int main(void)
{
puts(strerror(2));
puts(strerror(95));
puts(strerror(146));
return 0;
}
Conjecture: 2 is probably ENOENT, no such file or directory; 95 may be ENOTSOCK (not a socket); 146 might be ENOTSUPP (operation not supported).
On my system, the answer was in
/usr/include/sys/errno.h
:
- 2=ENOENT
- 95=ENOTSOCK
- 146=ECONNREFUSED
Note that error numbers up to the mid-twenties tend to be consistent across systems as the error codes existed in 7th Edition Unix. Higher numbers diverge. For example, on Mac OS X 10.9:
- 2 (ENOENT): No such file or directory
- 95 (EMULTIHOP): Reserved
- errno: no message for errno = 146
- ENOTSOCK (38): Socket operation on non-socket
- ECONNREFUSED (61): Connection refused
On SuSE (SLES 10 SP2 — antique, but these numbers don't change much):
- 2 (ENOENT): No such file or directory
- 95 (EOPNOTSUPP): Operation not supported on transport endpoint
- errno: no message for errno = 146
- ENOTSOCK (88): Socket operation on non-socket
- ECONNREFUSED (111): Connection refused
These answers were obtained via a program errno
that reports on error numbers and names. It has to be compiled for each different system.
Note that there is a consistent MySQL-provided component to the messages:
Can't connect to local MySQL server through socket '/dev/null' (95)
roughly as if the format string for the printf()
statement was:
"Can't connect to local MySQL server through socket '%s' (%s)\n"
The name of the 'socket' file is being provided — very helpful — and (educated guess) the system error number, collected at some point from errno
. However, errno
is volatile — almost any library function may set it to a non-zero value — so you need to preserve a specific value (copy it) before doing much in the way of error reporting work, such as reading message files to get the correct translation of the format string.