Cannot connect to local mysql server through socket [Solved]

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Cannot connect to local mysql server through socket [Solved]

Postby dbarasuk » 27. June 2012 11:07

Hi,
I'm glad to come into this forum. I'm seeking support to get mysql started. I mistankenly deleted the /tmp folder on my Red Hat Enterprise Linux 4 while mysql was running. After i switched off my computer i wan not able to start mysql anymore again with following error: can't connect to local mysql server through socket: /opt/lampp/var/mysql/mysql.sock (2).

Can someone tell me what i should do to get it started again?

Thank you for your kind support
dbarasuk
 
Posts: 4
Joined: 27. June 2012 10:47
Operating System: Red Hat Enterprise Linux 4

Re: Cannot connect to local mysql server through socket

Postby JonB » 27. June 2012 14:25

Take a look at this explanation and solution.

http://www.tech-recipes.com/rx/762/solv ... mysqlsock/

Of course you will need to change the paths in the fix, but it is likely the cause of your problem (its the MySQL client side)

See if this will solve your issue.

It is worth noting that LAMPP has a built-in backup, so when things are fixed, start making backups. (although I don't know if a backup could have fixed this problem)


Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Cannot connect to local mysql server through socket

Postby dbarasuk » 27. June 2012 15:18

hi JonB,
I got a look in the mysql config file located at /opt/lampp/etc/my.cnf and indeed the socket config file looks like: socket=/opt/lampp/var/mysql/mysql.sock. this is true for the client and server sides in the config file. both ports are 3306 for the client and for the server and still connection response shows that it cannot connect using the socket shown hereabove. However there is no socket file (mysql.sock) in this folder /opt/lampp/var/mysql. I think that my problem should be solved differently. If you have more ideas, please save me from this trouble because there are very important data i need to recover.
Kind regards
dbarasuk
 
Posts: 4
Joined: 27. June 2012 10:47
Operating System: Red Hat Enterprise Linux 4

Re: Cannot connect to local mysql server through socket

Postby JonB » 27. June 2012 19:31

When XAMPP/LAMPP is not running there will not be a mysql.sock file. Reason: as indicated in the post I referred to, the socket is actually a temporary stream. Technically its an inode

OK - Here is my Term session for you to look at: After stopping lampp - poof! no mysql.sock.
Code: Select all
[root@localhost /]# pwd
/
[root@localhost /]# cd /opt/lampp/var/mysql
[root@localhost mysql]# ls -l
total 28712
drwx------. 2 nobody root       4096 May  8 17:20 cdcol
-rw-rw----. 1 nobody nobody 18874368 Jun 27 13:53 ibdata1
-rw-rw----. 1 nobody nobody  5242880 Jun 27 13:54 ib_logfile0
-rw-rw----. 1 nobody nobody  5242880 May  8 17:23 ib_logfile1
-rw-rw----. 1 nobody root      10277 Jun 27 13:54 localhost.localdomain.err
-rw-rw----. 1 nobody nobody        5 Jun 27 13:54 localhost.localdomain.pid
drwx------. 2 nobody root       4096 May  8 17:20 mysql
srwxrwxrwx. 1 nobody nobody        0 Jun 27 13:54 mysql.sock
-rw-r--r--. 1 nobody root          5 May  8 17:20 mysql_upgrade_info
drwx------. 2 nobody root       4096 May  8 17:20 performance_schema
drwx------. 2 nobody root       4096 May  8 17:20 phpmyadmin
drwx------. 2 nobody root       4096 May  8 17:20 test
[root@localhost mysql]# /opt/lampp/lampp status
Version: XAMPP for Linux 1.7.7
Apache is running.
MySQL is running.
ProFTPD is running.
[root@localhost mysql]# /opt/lampp/lampp stop
Stopping XAMPP for Linux 1.7.7...
XAMPP: Stopping Apache with SSL...
XAMPP: Stopping MySQL...
XAMPP: Stopping ProFTPD...
XAMPP stopped.
[root@localhost mysql]# ls -l
total 28708
drwx------. 2 nobody root       4096 May  8 17:20 cdcol
-rw-rw----. 1 nobody nobody 18874368 Jun 27 13:57 ibdata1
-rw-rw----. 1 nobody nobody  5242880 Jun 27 13:57 ib_logfile0
-rw-rw----. 1 nobody nobody  5242880 May  8 17:23 ib_logfile1
-rw-rw----. 1 nobody root      10696 Jun 27 13:57 localhost.localdomain.err
drwx------. 2 nobody root       4096 May  8 17:20 mysql
-rw-r--r--. 1 nobody root          5 May  8 17:20 mysql_upgrade_info
drwx------. 2 nobody root       4096 May  8 17:20 performance_schema
drwx------. 2 nobody root       4096 May  8 17:20 phpmyadmin
drwx------. 2 nobody root       4096 May  8 17:20 test
[root@localhost mysql]#


Many times you will have to properly shutdown and restart to get thing straight. I suggest a /opt/lampp/lampp stop - followed by a server reset/reboot.

If that does not fix things:

A - Have you tried starting mysql with the /opt/lampp/lampp startmysql from the command line?

B. - Have you looked in /opt/lampp/var/mysql/localhost.localdomain.err (its an errors text file) If these things have not solved the problem, I suggest you paster the error file tail into your reply.

C. - Have you tinkered with permissions/ownership at all? - everything under /opt/lampp should belong to nobody:root

Good Luck
8)

A Unix domain socket or IPC socket (inter-process communication socket) is a data communications endpoint for exchanging data between processes executing within the same host operating system. While similar in functionality to named pipes, Unix domain sockets may be created as byte streams or as datagram sequences, while pipes are byte streams only. Processes using Unix domain sockets do not need to share a common ancestry. The API for Unix domain sockets is similar to that of an Internet socket, but it does not use an underlying network protocol for communication. The Unix domain socket facility is a standard component of POSIX operating systems.

Unix domain sockets use the file system as address name space. They are referenced by processes as inodes in the file system. This allows two processes to open the same socket in order to communicate. However, communication occurs entirely within the operating system kernel.

In addition to sending data, processes may send file descriptors across a Unix domain socket connection using the sendmsg() and recvmsg() system calls.

http://en.wikipedia.org/wiki/Unix_domain_socket

If you want more info - read through this topic:

http://www.linuxquestions.org/questions ... le-248399/
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Cannot connect to local mysql server through socket

Postby dbarasuk » 28. June 2012 18:25

Hi JonB,
I opened the error log and i think it has a lot of hints for those who know what's going on. Here is the full error message that was generated when i was trying to start mysqld:

120628 18:55:57 mysqld_safe mysqld from pid file /opt/lampp/var/mysql/RCMS.pid ended
120628 19:01:01 mysqld_safe Starting mysqld daemon with databases from /opt/lampp/var/mysql
120628 19:01:01 [Note] Plugin 'FEDERATED' is disabled.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use InnoDB's own implementation
InnoDB: Compressed tables use zlib 1.2.3
^G/opt/lampp/sbin/mysqld: Can't create/write to file '/tmp/ibvzIUFr' (Errcode: 13)
120628 19:01:01 InnoDB: Error: unable to create temporary file; errno: 13
120628 19:01:01 [ERROR] Plugin 'InnoDB' init function returned error.
120628 19:01:01 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
120628 19:01:01 [ERROR] Unknown/unsupported storage engine: InnoDB
120628 19:01:01 [ERROR] Aborting

120628 19:01:01 [Note] /opt/lampp/sbin/mysqld: Shutdown complete

120628 19:01:01 mysqld_safe mysqld from pid file /opt/lampp/var/mysql/RCMS.pid ended

It's like there are problems in the INNODB engine which cannot start properly, also, the mysqld not able to write to temporary folder /tmp probably while trying to create a mysql.sock file (I recall that the current problem happened consequent to a deletion of /tmp folder while mysqld was still running). All those errors leading to abortion of mysqld startup process.

When i look in the my.cnf configuration file residing in /opt/lampp/etc/ in the INNODB configuration section, this is what i find:

# Comment the following if you are using InnoDB tables
#skip-innodb
innodb_data_home_dir = /opt/lampp/var/mysql/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /opt/lampp/var/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50


Thank you for your prompt help,
Yours sincerely
dbarasuk
 
Posts: 4
Joined: 27. June 2012 10:47
Operating System: Red Hat Enterprise Linux 4

Re: Cannot connect to local mysql server through socket

Postby JonB » 28. June 2012 21:29

Its an OS issue - You need to re-create a proper tmp environment.

InnoDB: Compressed tables use zlib 1.2.3
^G/opt/lampp/sbin/mysqld: Can't create/write to file '/tmp/ibvzIUFr' (Errcode: 13)
120628 19:01:01 InnoDB: Error: unable to create temporary file; errno: 13

all applications need 'disk workspace' - normally that space is defined in the OS environment variable 'tmp' or 'temp'

Its exactly what you said in the first post, you wiped out the workspace that OS uses (or recreated it with improper ownership or permissions).

Things besides MySQL rely on the temp workspace - PHP usually stores its sessions variables there, and Perl uses it for file uploads via CGI. (among a long list of needs)

The /tmp folder is a special folder that is automatically dumped in most distributions on a reboot of the server. Its only used to process workfiles.

I have never had to re-create one BUT I do know it should be owned by 'root:root" and its permissions should be drwxrwxrwt - meaning all users have complete rights in it AND its a sticky folder (AFAIK) (that's what the final 't' is in the permissions).

Read this for sure:
http://en.wikipedia.org/wiki/Sticky_bit

http://www.redhat.com/mirrors/LDP/LDP/G ... sions.html

I urge you to either fix the issue or re-install the OS, as it is sure to mess you up at some point. I will say that it might be possible to create a different location for the tmp files used only by MySQL (you can also do that with PHP) but unless you understand a lot about how things work, its almost always a bad idea.

in /opt/lampp/etc/my.cnf, line 118 you will find the assignment of the tmpdir variable - IF the line is commented out, MySQL will use the OS tmp folder - thus your problem.

http://www.linuxforums.org/forum/server ... ctory.html

Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Cannot connect to local mysql server through socket

Postby dbarasuk » 29. June 2012 18:24

Hi JonB again,
thank you for your great support. I've found what was causing the startup failure and now I can start mysql again as many times as i want. In fact, in the /opt/lampp/etc/my.cnf, the tmpdir (which is set to /tmp) system variable was commented out which prevented mysqld from gaining access to the /tmp location thus the error 13, i commented it out and as you said i also made a chmod -R 777 /tmp. The two fixes brought the light by seeing mysql starting again.

Thank you for your involvement
dbarasuk
 
Posts: 4
Joined: 27. June 2012 10:47
Operating System: Red Hat Enterprise Linux 4

Re: Cannot connect to local mysql server through socket [Sol

Postby JonB » 29. June 2012 19:22

Great!

I'm glad it is working -

Good luck again
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 23 guests