Portal Home > Knowledgebase > Articles Database > Errr!, Can't connect to local MySQL server through socket


Errr!, Can't connect to local MySQL server through socket




Posted by SuperHosterz, 10-06-2007, 11:51 AM
mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) /home/thesymbi/public_html/includes/class_core.php on line 274 I get this around 50 times a day! I am fed up ! Please someone help me out urgently

Posted by ISPserver, 10-06-2007, 12:07 PM
Does mysql work correctly? usually "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock" means what mysql server not work. See to /var/log/message about memory usage and mysql error.

Posted by SuperHosterz, 10-06-2007, 12:10 PM
root@server ~]# /var/log/message -bash: /var/log/message: No such file or directory

Posted by voidSecurity, 10-06-2007, 12:18 PM
tail -f /var/log/message try restarting your mysql server ( /etc/init.d/mysql restart )

Posted by SuperHosterz, 10-06-2007, 12:25 PM
tail: cannot open `/var/log/message' for reading: No such file or directory tail: no files remaining Rebooted SQL 20 times a day still after sometime the error drops on my mail again and my sites says DB error

Posted by ISPserver, 10-06-2007, 12:39 PM
Sorry you need see to /var/log/messages not /var/log/message

Posted by SuperHosterz, 10-06-2007, 12:51 PM
root@server ~]# tail -f /var/log/messages Oct 6 11:24:54 server pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0 .0.1 Oct 6 11:24:54 server pure-ftpd: (?@127.0.0.1) [INFO] Logout. Oct 6 11:33:18 server pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0 .0.1 Oct 6 11:33:18 server pure-ftpd: (?@127.0.0.1) [INFO] Logout. Oct 6 11:41:41 server pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0 .0.1 Oct 6 11:41:41 server pure-ftpd: (?@127.0.0.1) [INFO] Logout. Oct 6 11:50:12 server pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0 .0.1 Oct 6 11:50:12 server pure-ftpd: (?@127.0.0.1) [INFO] Logout. Oct 6 11:50:36 server filelimits: Increasing file system limits succeeded Oct 6 11:50:42 server sshd(pam_unix)[5192]: session opened for user root by roo t(uid=0)

Posted by mooodi, 10-06-2007, 02:44 PM
See this link http://www.linuxquestions.org/questi...l.sock-281557/

Posted by SuperHosterz, 10-06-2007, 02:54 PM
My my.cnf already have those variables... here is my my.cnf [mysqld] safe-show-database #old_passwords back_log = 75 #skip-innodb max_connections = 350 key_buffer = 16M myisam_sort_buffer_size = 64M join_buffer_size = 1M read_buffer_size = 1M sort_buffer_size = 2M table_cache = 4000 thread_cache_size = 128 wait_timeout = 25 connect_timeout = 10 tmp_table_size = 32M max_heap_table_size = 32M max_allowed_packet = 32M max_connect_errors = 10 thread_concurrency = 8 read_rnd_buffer_size = 524288 bulk_insert_buffer_size = 8M query_cache_limit = 2M query_cache_size = 16M query_cache_type = 1 query_prealloc_size = 131072 query_alloc_block_size = 65536 default-storage-engine = MyISAM [mysqld_safe] nice = -10 open_files_limit = 8192 [mysqldump] quick max_allowed_packet = 16M [myisamchk] key_buffer = 64M nice = -10 open_files_limit = 8192 [mysqldump] quick max_allowed_packet = 16M [myisamchk] key_buffer = 64M sort_buffer = 64M read_buffer = 16M write_buffer = 16M [mysqlhotcopy] interactive-timeout

Posted by whmcsguru, 10-06-2007, 02:55 PM
after you start mysql, does it do anything? When you telnet to port 3306, does it do anything after mysql is started? If not, you may have more problems than you think. Make sure mysql has permission to read (and write) the /var/lib/mysql directories. In fact make everything under /var/lib/mysql (including /var/lib/mysql) owned by mysql.

Posted by SuperHosterz, 10-06-2007, 02:59 PM
root@server ~]# /etc/init.d/mysql start Starting MySQL SUCCESS! [root@server ~]# telnet localhost 3306 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. = 4.1.22-standardÕ(!m'r0,3OstnJhM'wD0Connection closed by foreign host.

Posted by whmcsguru, 10-06-2007, 03:01 PM
then the mysql command should work fine now. try from the command line, simply mysql.

Posted by SuperHosterz, 10-06-2007, 03:16 PM
it works.. It says welcome to SQL n all that

Posted by SuperHosterz, 10-07-2007, 12:40 AM
Again that error came 2-4 times... Please help

Posted by david510, 10-07-2007, 12:52 AM
It seems mysql is getting crashed. Check the file /var/lib/mysql/serverhostname.err file for any error. serverhostname should be replaced by your actual server hostname. You can find it by typing command hostname and press enter.

Posted by SuperHosterz, 10-07-2007, 01:05 AM
bash: var/lib/mysql/serverhostname.err: No such file or directory

Posted by david510, 10-07-2007, 01:25 AM
I am not sure if you looked the correct log file. From shell, type hostname and press enter. It would result like server.domain.com. Now open the file /var/lib/mysql/server.domain.com.err and check for errors.

Posted by SuperHosterz, 10-07-2007, 02:42 AM
There is a big file..How to select all text n paste here??

Posted by david510, 10-07-2007, 03:11 AM
tail -200 /var/lib/mysql/server.domain.com.err This will output the last 200 lines.

Posted by SuperHosterz, 10-07-2007, 03:14 AM
Here is the output

Posted by david510, 10-07-2007, 03:28 AM
Uncomment the line #skip-innodb (remove the #) in the /etc/my.cnf and restart mysql. Run the command below for sometime to see any errors are showing up. tail -f /var/lib/mysql/server.domain.com

Posted by SuperHosterz, 10-07-2007, 03:34 AM
got this...

Posted by david510, 10-07-2007, 03:43 AM
Ok wait for 10 to 15 minutes and issue the tail -f command to see any errors are showing up.

Posted by SuperHosterz, 10-07-2007, 05:55 AM
No error coming.. Will keep doing n keep informing

Posted by Scott.Mc, 10-07-2007, 12:39 PM
I am not sure why you were told to skip-innodb. If you use innodb tables then that would have been terrible advice. The reason you are having issues and having to restart mySQL is because it is unable to allocate the memory required for the tables. Can you provide the output of, free -m cat /proc/cpuinfo mysqladmin extended-status To help optimize your mySQL configuration.

Posted by SuperHosterz, 10-07-2007, 12:57 PM
here we go! Thanks

Posted by Scott.Mc, 10-07-2007, 01:06 PM
Try this for better caching, I have also added skip-innodb to it since you have already disabled this. After you restart mySQL truncate your mySQL error log so you can only see new errors, echo > /var/lib/mysql/`uname -n`.err

Posted by SuperHosterz, 10-07-2007, 01:12 PM
All Done Thanks for that mate.. Lets Check the result now..Will update here if any problem comes

Posted by SuperHosterz, 10-08-2007, 05:53 AM
Oh no! it came again Database error in vBulletin : mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) /home/thesymbi/public_html/includes/class_core.php on line 274

Posted by Scott.Mc, 10-08-2007, 07:46 AM
ok and what does your mySQL configuration error with now? cat /var/lib/mysql/`uname -n`.err

Posted by SuperHosterz, 10-08-2007, 12:46 PM
root@server ~]# cat /var/lib/mysql/`uname -n`.err 071008 4:19:27 [Note] /usr/sbin/mysqld: Normal shutdown 071008 4:19:27 [Note] /usr/sbin/mysqld: Shutdown complete 071008 04:19:27 mysqld ended 071008 04:19:28 mysqld started /usr/sbin/mysqld: ready for connections. Version: '4.1.22-standard' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Edition - Standard (GPL)

Posted by Scott.Mc, 10-08-2007, 01:32 PM
Your daemon did not dump memory errors and was simply restarted. Did you restart it yourself? If not then you have something running that is restarting it such as SIM. Also going on your basic enviornment from what I can tell in this thread I assume you are running cPanel so you might want to check the chkserv logs in /var/log aswell.

Posted by SuperHosterz, 10-08-2007, 01:47 PM
My friend rebooted SQL , he told me now..

Posted by Scott.Mc, 10-08-2007, 03:15 PM
Then that's your problem, your "friend" should not just be randomly restarting mySQL it does not need restarted. That is why you got the email error because he restarted mySQL.

Posted by SuperHosterz, 10-08-2007, 09:29 PM
Database error in vBulletin 3.6.8: Invalid SQL: SELECT filename, attachment.postid, attachment.userid, attachmentid, attachment.dateline, SUBSTRING(filedata, 1, 2097152) AS filedata, filesize, attachment.visible, mimetype, thread.forumid, thread.threadid, thread.postuserid, post.visible AS post_visible, thread.visible AS thread_visible FROM attachment AS attachment LEFT JOIN attachmenttype AS attachmenttype ON (attachmenttype.extension = attachment.extension) LEFT JOIN post AS post ON (post.postid = attachment.postid) LEFT JOIN thread AS thread ON (post.threadid = thread.threadid) WHERE attachmentid = 2447; MySQL Error : Out of memory (Needed 2097224 bytes) How do I fix this?

Posted by SuperHosterz, 10-09-2007, 12:00 PM
Today again I got the same error : Can't connect to local MySQL server through Fired cat /var/lib/mysql/`uname -n`.err Got :

Posted by Scott.Mc, 10-09-2007, 02:26 PM
Sorry didn't see this. Your mySQL is still wanting more memory, "Got error 12 when reading table './thesymbi_vb/language'" Which means mySQL is trying to use more memory than what is available, now lowering the necessary setings in the config would stop it trying to allocate more memory but in turn would mean the site would have constant issues with mySQL hanging. So the option is to add more ram, just remember that once you have more ram added you will have to reconfigure mySQL to reflect the new ram values.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
SPF record help! (Views: 482)
Change host provider (Views: 482)