Help! mysql.sock missing mysteriously

Hello All,

Im having a issue with a database server, suddenly the var directory got full so i cleared out some extra log files and the like and restarted the server.

Now mysql will not start, i have mysql_enabled in my rc.conf and set to yes. I can tell that mysql is not running and it is complaining about

Error 2002 (HY000) Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I know the file use to exist in that location, however it does not now.

Phpmyadmin also produces the error message:

#2013 - Lost connection to MySQL server at 'reading initial communication packet', system error: 61

My question is what to do now, How to properly start mysql and recreate the mysql.sock file ?
 
As far as I can see, the command [cmd=]/usr/local/etc/rc.d/mysql-server start[/cmd] or [cmd=]/usr/local/etc/rc.d/mysql-server restart[/cmd] touches/recreates /tmp/mysql.lock. I clear /tmp on every reboot (well, the system does), and mysql starts fine at boot time.

What is the output of [cmd=]/usr/local/etc/rc.d/mysql-server rcvar[/cmd] and [cmd=]/usr/local/etc/rc.d/mysql-server status[/cmd]?
 
/usr/local/etc/rc.d/mysql-server status
mysql is not running.

/usr/local/etc/rc.d/mysql-server rcvar
# mysql
mysql_enable=YES

also it appears there is a error log generated

Code:
090904 11:54:34 mysqld_safe Starting mysqld daemon with databases from /var/db/mysql
090904 11:54:35  InnoDB: Started; log sequence number 9 884474847
^G/usr/local/libexec/mysqld: File './mysql-bin.000023' not found (Errcode: 2)
090904 11:54:35 [ERROR] Failed to open log (file './mysql-bin.000023', errno 2)
090904 11:54:35 [ERROR] Could not open log file
090904 11:54:35 [ERROR] Can't init tc log
090904 11:54:35 [ERROR] Aborting

090904 11:54:35  InnoDB: Starting shutdown...
090904 11:54:36  InnoDB: Shutdown completed; log sequence number 9 884474847
090904 11:54:36 [Warning] Forcing shutdown of 1 plugins
090904 11:54:36 [Note] /usr/local/libexec/mysqld: Shutdown complete

090904 11:54:36 mysqld_safe mysqld from pid file /var/db/mysql/sstdatabase.selectsst.com.pid ended
090904 11:57:54 mysqld_safe Starting mysqld daemon with databases from /var/db/mysql
090904 11:57:54  InnoDB: Started; log sequence number 9 884474847
/usr/local/libexec/mysqld: Too many arguments (first extra is 'start').
Use --verbose --help to get a list of available options
090904 11:57:54 [ERROR] Aborting

090904 11:57:54  InnoDB: Starting shutdown...
090904 11:57:56  InnoDB: Shutdown completed; log sequence number 9 884474847
090904 11:57:56 [Warning] Forcing shutdown of 1 plugins
090904 11:57:56 [Note] /usr/local/libexec/mysqld: Shutdown complete

090904 11:57:56 mysqld_safe mysqld from pid file /var/db/mysql/sstdatabase.selectsst.com.pid ended
090904 11:59:58 mysqld_safe Starting mysqld daemon with databases from /var/db/mysql
090904 11:59:58  InnoDB: Started; log sequence number 9 884474847
^G/usr/local/libexec/mysqld: File './mysql-bin.000023' not found (Errcode: 2)
090904 11:59:58 [ERROR] Failed to open log (file './mysql-bin.000023', errno 2)
090904 11:59:58 [ERROR] Could not open log file
090904 11:59:58 [ERROR] Can't init tc log
090904 11:59:58 [ERROR] Aborting

090904 11:59:58  InnoDB: Starting shutdown...
090904 12:00:00  InnoDB: Shutdown completed; log sequence number 9 884474847
090904 12:00:00 [Warning] Forcing shutdown of 1 plugins
090904 12:00:00 [Note] /usr/local/libexec/mysqld: Shutdown complete

090904 12:00:00 mysqld_safe mysqld from pid file /var/db/mysql/sstdatabase.selectsst.com.pid ended
090904 12:00:44 mysqld_safe Starting mysqld daemon with databases from /var/db/mysql
090904 12:00:44  InnoDB: Started; log sequence number 9 884474847
^G/usr/local/libexec/mysqld: File './mysql-bin.000023' not found (Errcode: 2)
090904 12:00:44 [ERROR] Failed to open log (file './mysql-bin.000023', errno 2)
090904 12:00:44 [ERROR] Could not open log file
090904 12:00:44 [ERROR] Can't init tc log
090904 12:00:44 [ERROR] Aborting

090904 12:00:44  InnoDB: Starting shutdown...
090904 12:00:45  InnoDB: Shutdown completed; log sequence number 9 884474847
090904 12:00:45 [Warning] Forcing shutdown of 1 plugins
090904 12:00:45 [Note] /usr/local/libexec/mysqld: Shutdown complete

090904 12:00:45 mysqld_safe mysqld from pid file /var/db/mysql/sstdatabase.selectsst.com.pid ended
090904 12:00:59 mysqld_safe Starting mysqld daemon with databases from /var/db/mysql
090904 12:00:59  InnoDB: Started; log sequence number 9 884474847
^G/usr/local/libexec/mysqld: File './mysql-bin.000023' not found (Errcode: 2)
090904 12:00:59 [ERROR] Failed to open log (file './mysql-bin.000023', errno 2)
090904 12:00:59 [ERROR] Could not open log file
090904 12:00:59 [ERROR] Can't init tc log
090904 12:00:59 [ERROR] Aborting

090904 12:00:59  InnoDB: Starting shutdown...
090904 12:01:01  InnoDB: Shutdown completed; log sequence number 9 884474847
090904 12:01:01 [Warning] Forcing shutdown of 1 plugins
090904 12:01:01 [Note] /usr/local/libexec/mysqld: Shutdown complete

090904 12:01:01 mysqld_safe mysqld from pid file /var/db/mysql/sstdatabase.selectsst.com.pid ended
 
What are the permissions of /var/db/mysql? And is that directory and everything under it owned my mysql:mysql?

Code:
# ls -ld /var/db/mysql/
drwx------  7 mysql  mysql  512 Sep  4 23:10 /var/db/mysql/

All directories in /var/db/mysql should be 700, and all files 660.
 
they directory and the files in it all all set to mysql

Code:
/var/db% ll
total 1562
drwxr-xr-x    2 messagebus  messagebus      512 Jul 14 03:50 dbus
----------    1 root        wheel           385 Jul 14 11:12 dhclient.leases.re0
drwx------    2 operator    operator        512 Sep  4 12:33 entropy
drwxr-xr-x    2 root        wheel           512 Jul 14 03:56 fontconfig
drwxr-xr-x    2 root        wheel           512 Apr 30 23:04 freebsd-update
drwx------    2 root        wheel           512 Apr 30 23:04 ipf
-r--r--r--    1 nobody      wheel       1552583 Aug 29 04:15 locate.database
-rw-r--r--    1 root        wheel             0 Jul 14 04:00 mountdtab
drwxrwxrwx    4 mysql       mysql          1024 Sep  4 12:35 mysql
drwxr-xr-x  208 root        wheel          6144 Jul 14 11:30 pkg
drwxr-xr-x    2 root        wheel           512 Apr 30 23:04 ports
drwxr-xr-x    3 root        wheel           512 Jul 31 08:41 portsnap
drwxr-xr-x    3 root        wheel           512 Jul 31 09:49 sup

and the files inside

Code:
-rw-r--r--  1 mysql  mysql       50994 Sep  4 12:14 equence number 9 884474847
-rw-r--r--  1 mysql  mysql       11156 Sep  4 12:14 hutdown...
-rwxrwxrwx  1 mysql  mysql     5242880 Sep  4 12:35 ib_logfile0
-rwxrwxrwx  1 mysql  mysql     5242880 Sep  4 10:41 ib_logfile1
-rwxrwxrwx  1 mysql  mysql   513802240 Sep  4 12:35 ibdata1
drwxrwxrwx  2 mysql  mysql       10240 Sep  2 14:19 magento_cctv
drwxrwxrwx  2 mysql  mysql        2048 Jul 14 11:37 mysql
-rwxrwxrwx  1 mysql  mysql    19401485 Sep  4 11:05 mysql-bin.000001
-rwxrwxrwx  1 mysql  mysql   155516928 Sep  4 11:14 mysql-bin.000006
-rwxrwxrwx  1 mysql  mysql  1073741957 Sep  4 11:13 mysql-bin.000007
-rwxrwxrwx  1 mysql  mysql   231983092 Sep  4 11:13 mysql-bin.000008
-rwxrwxrwx  1 mysql  mysql   307225682 Sep  4 11:12 mysql-bin.000009
-rwxrwxrwx  1 mysql  mysql   348392257 Sep  4 11:12 mysql-bin.000010
-rwxrwxrwx  1 mysql  mysql  1073742167 Sep  4 11:12 mysql-bin.000011
-rwxrwxrwx  1 mysql  mysql  1073742007 Sep  4 11:11 mysql-bin.000012
-rwxrwxrwx  1 mysql  mysql  1073742333 Sep  4 11:10 mysql-bin.000013
-rwxrwxrwx  1 mysql  mysql  1073749906 Sep  4 11:09 mysql-bin.000014
-rwxrwxrwx  1 mysql  mysql  1073742072 Sep  4 11:09 mysql-bin.000015
-rwxrwxrwx  1 mysql  mysql  1073742238 Sep  4 11:08 mysql-bin.000016
-rwxrwxrwx  1 mysql  mysql  1073742109 Sep  4 11:07 mysql-bin.000017
-rwxrwxrwx  1 mysql  mysql  1073741877 Sep  4 11:06 mysql-bin.000018
-rwxrwxrwx  1 mysql  mysql   292618240 Sep  4 11:05 mysql-bin.000019
-rwxrwxrwx  1 mysql  mysql         125 Sep  4 11:05 mysql-bin.000021
-rwxrwxrwx  1 mysql  mysql         419 Sep  4 12:25 mysql-bin.index
-rwxr-xr-x  1 mysql  mysql         437 Sep  4 12:25 mysql-bin.index.bak
-rwxrwxrwx  1 mysql  mysql       43614 Sep  4 12:35 sstdatabase.selectsst.com.err

also i am missig the mysql-bin.00023 so i changed the index to not include it
 
That looks decidely weird.

Suggestion:

Code:
find /var/db/mysql -type d | xargs chmod 700
find /var/db/mysql -type f | xargs chmod 660
 
Your problem seems to be a missing mysql-bin.000023 binary log file. You may be accidentally deleted this file.

The /tmp/mysql.sock file should not be existing while the server is down, this is a normal behavior. The mysqld creates it when it starts up.

No to solve your problem, you should disable bin-logging in the mysql config file, which is conventionally found in /usr/local/etc/my.cnf. Open that file and find a line that reads: log-bin=mysql-bin and comment it out. You should be able to start mysql-server as usual.

Let me know if this solves your problem.
 
Whoa, I had some intense fear there for a second

but after doing unixeagle / dutchdaemon's suggestions it appears to be working

THANK YOU SO MUCH, YOUR THE BEST!

PS - How to mark the thread solved ?
 
have the same problem file is missing for some time
Code:
# /usr/local/etc/rc.d/mysql-server status
mysql is running as pid 17988.

 /usr/local/etc/rc.d/mysql-server rcvar
# mysql
#
mysql_enable="YES"
#   (default: "")
 
Maybe you have a process running that deletes content from /tmp?
 
Perhaps you enabled daily_clean_tmps_enable in periodic.conf? That could potentially delete it.
 
in /etc/defaults/periodic.conf
Code:
daily_clean_tmps_enable="NO"                            # Delete stuff daily
daily_clean_tmps_dirs="/tmp"                            # Delete under here
daily_clean_tmps_days="3"                               # If not accessed for
daily_clean_tmps_ignore=".X*-lock .X11-unix .ICE-unix .font-unix .XIM-unix"
daily_clean_tmps_ignore="$daily_clean_tmps_ignore quota.user quota.group .snap"
                                                        # Don't delete these
daily_clean_tmps_verbose="YES"                          # Mention files deleted

I see ther is NO.
 
Yes, but you can overrule those in /etc/periodic.conf. However, if that file doesn't exist it's safe to assume the defaults.

Other options are custom scripts running through crontab(1) for example.
 
I have found in crontab sh file with
THAT
every 12 hours
rm -rf /tmp/*

Previos admin work.
Chek tomorrow and replay.
Thank you very mach!
 
Back
Top