Portal Home > Knowledgebase > Articles Database > Can't connect to local MySQL server ...
Can't connect to local MySQL server ...
Posted by Ilan, 07-27-2012, 05:11 AM |
Im getting the following error for a website...
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (11) in /home/xxxxxxx/public_html/serverstats/config.php on line 48
I cannot connect to the database because: Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (11)
All website have database also same error, please help me soon.
Any ideas are appreciated.
Thank you verry much.
|
Posted by matt1206, 07-27-2012, 05:18 AM |
Is MySQL actually up and running on the server?
|
Posted by Ilan, 07-27-2012, 05:25 AM |
Yes, every time I have to restart MySQL with this command.
# service mysql restart
But again it happen over and over again.
|
Posted by protocol1, 07-27-2012, 05:37 AM |
Have a look at the error logs
try
# tail /var/lib/mysql/*.err
|
Posted by Ilan, 07-27-2012, 05:45 AM |
tail /var/lib/mysql/*.err display:
root@wolverine [~]# tail /var/lib/mysql/*.err
120727 5:15:25 InnoDB: Warning: allocated tablespace 340, old maximum was 0
120727 5:15:25 InnoDB: 1.1.8 started; log sequence number 101002117
120727 5:15:25 [Note] Server hostname (bind-address): '(null)'; port: 3306
120727 5:15:25 [Note] - '(null)' resolves to '::';
120727 5:15:25 [Note] - '(null)' resolves to '0.0.0.0';
120727 5:15:25 [Note] Server socket created on IP: '0.0.0.0'.
120727 5:15:25 [Note] Event Scheduler: Loaded 0 events
120727 5:15:25 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.24-cll' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)
120727 05:23:41 mysqld_safe A mysqld process already exists
root@wolverine [~]#
|
Posted by protocol1, 07-27-2012, 06:12 AM |
see if you can connect to mysql on the command line ok:
# mysql
|
Posted by Ilan, 07-27-2012, 06:16 AM |
The command.
# mysql
display:
root@wolverine [~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6077
Server version: 5.5.24-cll MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
|
Posted by madaboutlinux, 07-27-2012, 06:23 AM |
tail" will show you only last 10 lines of the error file.. open the mysql log file and go through today's logs to see what it states before Mysql service was restarted.
|
Posted by protocol1, 07-27-2012, 06:25 AM |
check the permissions on the socket:
# ls -al /var/lib/mysql/mysql.sock
is this a cpanel server? forcing mysql reinstall (keeps data) often fixes issues
# /scripts/mysqlup --force
|
Posted by Ilan, 07-27-2012, 06:38 AM |
I am sorry. what command is for this request.
Thank you.
|
Posted by Ilan, 07-27-2012, 06:43 AM |
Yes, is cPanel server.
command:
# ls -al /var/lib/mysql/mysql.sock
display:
root@wolverine [~]# ls -al /var/lib/mysql/mysql.sock
srwxrwxrwx 1 mysql mysql 0 Jul 27 05:15 /var/lib/mysql/mysql.sock=
root@wolverine [~]#
|
Posted by madaboutlinux, 07-27-2012, 06:59 AM |
If the problem has happened today, use the following:
where,
120727 is todays date and
hostname is the actual hostname of your server.
|
Posted by Ilan, 07-27-2012, 07:04 AM |
No such file or directory ?
root@wolverine [~]# grep 120727 /var/lib/mysql/hostname.err
grep: /var/lib/mysql/hostname.err: No such file or directory
root@wolverine [~]#
|
Posted by madaboutlinux, 07-27-2012, 07:08 AM |
You have used the filename as it is.. you have to replace 'hostname' with the actual hostname of your server. The hostname of your server starts with wolverine.. for complete hostname type:
then replace "hostname" in the below command with the output of the above command
|
Posted by Ilan, 07-27-2012, 07:16 AM |
okay,
Display:
120727 4:30:34 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:34 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:34 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:34 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:35 [ERROR] /usr/sbin/mysqld: Can't open file: './erotizat_eros2012/w_configuracion.frm' (errno: 24)
120727 4:30:35 [ERROR] /usr/sbin/mysqld: Can't open file: './erotizat_eros2012/p_categorias.frm' (errno: 24)
120727 4:30:35 [ERROR] /usr/sbin/mysqld: Can't open file: './erotizat_eros2012/u_sessions.frm' (errno: 24)
120727 4:30:35 [ERROR] /usr/sbin/mysqld: Can't open file: './erotizat_eros2012/u_miembros.frm' (errno: 24)
120727 4:30:36 [ERROR] /usr/sbin/mysqld: Can't open file: './pimp_amateurland/smf_settings.frm' (errno: 24)
120727 4:30:37 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:37 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:37 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:37 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:37 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:37 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:38 [ERROR] /usr/sbin/mysqld: Sort aborted: Out of resources when opening file '/tmp/MYkvDemN' (Errcode: 24)
120727 4:30:39 [ERROR] /usr/sbin/mysqld: Sort aborted: Out of resources when opening file '/tmp/MYuvAF1U' (Errcode: 24)
120727 4:30:40 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:40 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:40 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:40 [ERROR] /usr/sbin/mysqld: Sort aborted: Out of resources when opening file '/tmp/MYLetd7d' (Errcode: 24)
120727 4:30:41 [ERROR] /usr/sbin/mysqld: Can't open file: './pimp_amateurland/smf_settings.frm' (errno: 24)
120727 4:30:41 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:41 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:41 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:42 [ERROR] /usr/sbin/mysqld: Can't open file: './ibizameg_new/jos_session.frm' (errno: 24)
120727 4:30:42 [ERROR] /usr/sbin/mysqld: Can't open file: './ibizameg_new/jos_session.frm' (errno: 24)
120727 4:30:42 [ERROR] /usr/sbin/mysqld: Can't open file: './ibizameg_new/jos_session.frm' (errno: 24)
120727 4:30:42 [ERROR] /usr/sbin/mysqld: Can't open file: './ibizameg_new/jos_session.frm' (errno: 24)
120727 4:30:42 [ERROR] /usr/sbin/mysqld: Can't open file: './ibizameg_new/jos_session.frm' (errno: 24)
120727 4:30:44 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:44 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:44 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:45 [ERROR] /usr/sbin/mysqld: Can't open file: './pimp_amateurland/smf_settings.frm' (errno: 24)
120727 4:30:45 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:45 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:45 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:46 [ERROR] /usr/sbin/mysqld: Can't open file: './tecnobit_tecno/smf_comentarios.frm' (errno: 24)
120727 4:30:46 [ERROR] /usr/sbin/mysqld: Sort aborted: Out of resources when opening file '/tmp/MYBiGXoM' (Errcode: 24)
120727 4:30:46 [ERROR] /usr/sbin/mysqld: Sort aborted: Out of resources when opening file '/tmp/MYEnkfiB' (Errcode: 24)
120727 4:30:47 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:47 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:47 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:48 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:48 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:48 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:49 [ERROR] /usr/sbin/mysqld: Can't open file: './ademu_ademu/jos_session.frm' (errno: 24)
120727 4:30:49 [ERROR] /usr/sbin/mysqld: Can't open file: './ademu_ademu/jos_session.frm' (errno: 24)
120727 4:30:49 [ERROR] /usr/sbin/mysqld: Can't open file: './ademu_ademu/jos_session.frm' (errno: 24)
120727 4:30:49 [ERROR] /usr/sbin/mysqld: Can't open file: './ademu_ademu/jos_session.frm' (errno: 24)
120727 4:30:49 [ERROR] /usr/sbin/mysqld: Can't open file: './ademu_ademu/jos_session.frm' (errno: 24)
120727 4:30:49 [ERROR] /usr/sbin/mysqld: Can't open file: './ademu_ademu/jos_session.frm' (errno: 24)
120727 4:30:50 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:50 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:50 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:50 [ERROR] /usr/sbin/mysqld: Sort aborted: Out of resources when opening file '/tmp/MYoCPdT9' (Errcode: 24)
120727 4:30:51 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:51 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:51 [ERROR] /usr/sbin/mysqld: Can't open file: './noticias_noticias/wp_options.frm' (errno: 24)
120727 4:30:52 [ERROR] /usr/sbin/mysqld: Sort aborted: Out of resources when opening file '/tmp/MYLrWig2' (Errcode: 24)
120727 4:30:53 [ERROR] /usr/sbin/mysqld: Can't open file: './pimp_amateurland/smf_settings.frm' (errno: 24)
120727 4:30:54 [ERROR] /usr/sbin/mysqld: Sort aborted: Out of resources when opening file '/tmp/MYxi2r56' (Errcode: 24)
120727 4:30:54 [ERROR] /usr/sbin/mysqld: Sort aborted: Out of resources when opening file '/tmp/MYbCF5Xg' (Errcode: 24)
120727 4:32:46 [Note] /usr/sbin/mysqld: Normal shutdown
120727 4:32:46 [Note] Event Scheduler: Purging the queue. 0 events
120727 4:32:48 [Warning] /usr/sbin/mysqld: Forcing close of thread 12041 user: 'leechprotect'
120727 4:32:48 [Warning] /usr/sbin/mysqld: Forcing close of thread 29 user: 'root'
120727 4:32:48 [Warning] /usr/sbin/mysqld: Forcing close of thread 27 user: 'eximstats'
120727 4:32:48 InnoDB: Starting shutdown...
120727 4:32:49 InnoDB: Shutdown completed; log sequence number 101002107
120727 4:32:49 [Note] /usr/sbin/mysqld: Shutdown complete
120727 04:32:49 mysqld_safe mysqld from pid file /var/lib/mysql/wolverine.xxxxx.com.pid ended
120727 04:32:49 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120727 4:32:49 [Note] Plugin 'FEDERATED' is disabled.
120727 4:32:49 InnoDB: The InnoDB memory heap is disabled
120727 4:32:49 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120727 4:32:49 InnoDB: Compressed tables use zlib 1.2.3
120727 4:32:49 InnoDB: Using Linux native AIO
120727 4:32:49 InnoDB: Initializing buffer pool, size = 128.0M
120727 4:32:49 InnoDB: Completed initialization of buffer pool
120727 4:32:49 InnoDB: highest supported file format is Barracuda.
120727 4:32:49 InnoDB: Warning: allocated tablespace 340, old maximum was 0
120727 4:32:49 InnoDB: 1.1.8 started; log sequence number 101002107
120727 4:32:50 [Note] Server hostname (bind-address): '(null)'; port: 3306
120727 4:32:50 [Note] - '(null)' resolves to '::';
120727 4:32:50 [Note] - '(null)' resolves to '0.0.0.0';
120727 4:32:50 [Note] Server socket created on IP: '0.0.0.0'.
120727 4:32:50 [Note] Event Scheduler: Loaded 0 events
120727 4:32:50 [Note] /usr/sbin/mysqld: ready for connections.
120727 4:59:13 [Note] /usr/sbin/mysqld: Normal shutdown
120727 4:59:13 [Note] Event Scheduler: Purging the queue. 0 events
120727 4:59:15 [Warning] /usr/sbin/mysqld: Forcing close of thread 703 user: 'root'
120727 4:59:15 [Warning] /usr/sbin/mysqld: Forcing close of thread 16 user: 'eximstats'
120727 4:59:15 InnoDB: Starting shutdown...
120727 4:59:17 InnoDB: Shutdown completed; log sequence number 101002117
120727 4:59:17 [Note] /usr/sbin/mysqld: Shutdown complete
120727 04:59:17 mysqld_safe mysqld from pid file /var/lib/mysql/wolverine.xxxxx.com.pid ended
120727 04:59:17 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120727 4:59:17 [Note] Plugin 'FEDERATED' is disabled.
120727 4:59:17 InnoDB: The InnoDB memory heap is disabled
120727 4:59:17 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120727 4:59:17 InnoDB: Compressed tables use zlib 1.2.3
120727 4:59:17 InnoDB: Using Linux native AIO
120727 4:59:17 InnoDB: Initializing buffer pool, size = 128.0M
120727 4:59:17 InnoDB: Completed initialization of buffer pool
120727 4:59:17 InnoDB: highest supported file format is Barracuda.
120727 4:59:17 InnoDB: Warning: allocated tablespace 340, old maximum was 0
120727 4:59:17 InnoDB: Waiting for the background threads to start
120727 4:59:18 InnoDB: 1.1.8 started; log sequence number 101002117
120727 4:59:18 [Note] Server hostname (bind-address): '(null)'; port: 3306
120727 4:59:18 [Note] - '(null)' resolves to '::';
120727 4:59:18 [Note] - '(null)' resolves to '0.0.0.0';
120727 4:59:18 [Note] Server socket created on IP: '0.0.0.0'.
120727 4:59:18 [Note] Event Scheduler: Loaded 0 events
120727 4:59:18 [Note] /usr/sbin/mysqld: ready for connections.
120727 5:15:22 [Note] /usr/sbin/mysqld: Normal shutdown
120727 5:15:22 [Note] Event Scheduler: Purging the queue. 0 events
120727 5:15:22 [ERROR] /usr/sbin/mysqld: Sort aborted: Server shutdown in progress
120727 5:15:24 [Warning] /usr/sbin/mysqld: Forcing close of thread 1264 user: 'root'
120727 5:15:24 [Warning] /usr/sbin/mysqld: Forcing close of thread 704 user: 'leechprotect'
120727 5:15:24 [Warning] /usr/sbin/mysqld: Forcing close of thread 58 user: 'eximstats'
120727 5:15:24 InnoDB: Starting shutdown...
120727 5:15:25 InnoDB: Shutdown completed; log sequence number 101002117
120727 5:15:25 [Note] /usr/sbin/mysqld: Shutdown complete
120727 05:15:25 mysqld_safe mysqld from pid file /var/lib/mysql/wolverine.xxxxx.com.pid ended
120727 05:15:25 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120727 5:15:25 [Note] Plugin 'FEDERATED' is disabled.
120727 5:15:25 InnoDB: The InnoDB memory heap is disabled
120727 5:15:25 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120727 5:15:25 InnoDB: Compressed tables use zlib 1.2.3
120727 5:15:25 InnoDB: Using Linux native AIO
120727 5:15:25 InnoDB: Initializing buffer pool, size = 128.0M
120727 5:15:25 InnoDB: Completed initialization of buffer pool
120727 5:15:25 InnoDB: highest supported file format is Barracuda.
120727 5:15:25 InnoDB: Warning: allocated tablespace 340, old maximum was 0
120727 5:15:25 InnoDB: 1.1.8 started; log sequence number 101002117
120727 5:15:25 [Note] Server hostname (bind-address): '(null)'; port: 3306
120727 5:15:25 [Note] - '(null)' resolves to '::';
120727 5:15:25 [Note] - '(null)' resolves to '0.0.0.0';
120727 5:15:25 [Note] Server socket created on IP: '0.0.0.0'.
120727 5:15:25 [Note] Event Scheduler: Loaded 0 events
120727 5:15:25 [Note] /usr/sbin/mysqld: ready for connections.
120727 05:23:41 mysqld_safe A mysqld process already exists
120727 7:06:40 [Warning] IP address '61.147.103.92' could not be resolved: Name or service not known
root@wolverine [~]#
Last edited by Ilan; 07-27-2012 at 07:20 AM.
|
Posted by madaboutlinux, 07-27-2012, 07:30 AM |
The logs indicate the server is running out of resources while performing some task. Have someone login and look into the server for you.
|
Posted by Ilan, 07-27-2012, 07:50 AM |
Not have someone login and look into the server, thank you for your assessment.
Already understand what is happening with the server
|
Posted by madaboutlinux, 07-27-2012, 07:51 AM |
Glad to hear you managed to figure out the cause..
|
Posted by Ilan, 07-27-2012, 06:51 PM |
It seems that the problem is for denial of service attack.
I have installed --- "(D)DoS Deflate" --- and the server this stable throughout the day.
What other security measures I can install?
|
Posted by Ilan, 07-28-2012, 08:16 PM |
Guys, thank for this help and thanks especially to madaboutlinux.
|
Posted by olddocks, 07-30-2012, 11:10 AM |
Try
You might want to check this out
|
Add to Favourites Print this Article
Also Read