LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-28-2004, 11:05 AM   #1
enigma82
Member
 
Registered: Sep 2004
Location: Fagaras, Romania
Distribution: Mandrake 10.0
Posts: 48

Rep: Reputation: 15
how can I create a socket file?


I have a problem: I accidentally erased my socket file in mysql. Anybody knows how I can create that file back? I tried copying a socket file from another location and renaming it but it didn't work.
 
Old 10-28-2004, 02:00 PM   #2
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 51
i'm not so sure you can make that by hand -- seems like the programm will have to
was it in /tmp
if so it might just be a link to something like
ln -sf /var/lib/mysql/mysql.sock /tmp/mysql.sock
or something like that
otherwise seems like a restart

mysqladmin [-h ... -u ... -p...] shutdown
mysqld_safe --user=mysql &

should recreate

if it's suposed to be in tmp make sure mysql has write permission
 
Old 10-29-2004, 04:28 AM   #3
enigma82
Member
 
Registered: Sep 2004
Location: Fagaras, Romania
Distribution: Mandrake 10.0
Posts: 48

Original Poster
Rep: Reputation: 15
I tried all that and after giving mysql a restart command it says that it does but after issuing a mysql status command I find out that it didn't. (I haven't worked with mysql up until now)
That socket file isn't supposed to be in /tmp. It is the default config on MDK10 and it is in /var/lib/mysql i think (I am not in front of my pc).
After trying all sort of things it finally recreated the socket file but it still says that it cannot connect to mysql server through the socket file.
From what I read through man pages and other docs I figured that the socket file is a special file whose perms look like this: srw-rw-rw- (is this correct?) I copied another socket file and chown'ed it in order to make the mysql group/mysql user owner of that file and still nothing.
Any more ideas? I really need help! I lost my MDK cd's and until I recover them to reinstall (the ultimate solution!!!) I need that freakin' mysql running!
 
Old 12-06-2004, 10:39 PM   #4
GinEric
Member
 
Registered: Nov 2004
Location: Earth
Distribution: Slackware 10, et ux
Posts: 36

Rep: Reputation: 15
That has got to be one of the biggest problems with MySQL!

Everyone everywhere is getting this stupid can't connect on mysql.sock and there is nothing at their site or on the Internet saying why this happens.

Further, there should be a way to make a simple socket file, and you can't find that anywhere either.

From what I've read, the temporary file is created in the mysql directory, while KDE tries to create her own sockets, temporary ones in /tmp

There are problems with pthreads, and so on, but if the MySQL development team would go after this bug, they might get a lot of disconnection errors fixed.

The distribution should come with a copy of the socket file and not depend on C++ to have one compiled in without any recourse.

It really is beginning to look like MySQL team did not know what it was doing with sockets, auths, and a lot more. A socket should be a simple thing and it should work, without the really stupid error message "can't connect using socket," of course it can't connect dummy, but why can't it connect?

Using this page:

http://www.linuxquestions.org/questions/history/256378

here, I created the mysql.sock file and echo'ed a null character to it. I created this in /var/run/mysql but as it turns out the file created is a pipe and not a socket, which may dismay the author of the other article a bit. Perhaps there is a mksocket command [no such luck!].

If you found an answer, please reply.
 
Old 08-28-2007, 02:43 PM   #5
GreyBeard
LQ Newbie
 
Registered: Oct 2003
Location: Taxachusetts, USA
Distribution: Slackware
Posts: 25

Rep: Reputation: 0
Question How do I create a "socket file" redux?

This topic was originally posted about 2.75 years ago. Has anyone
figured out in the interim how to create a "socket file"? They are
sitting here on this Linux machine I am using, eg:

bash> ls -F /tmp/.X11-unix/X0
/tmp/.X11-unix/X0=

bash> file /tmp/.X11-unix/X0
/tmp/.X11-unix/X0: socket

I have been totally unsuccessful in finding a program or series of
programs which will create one of these puppies for me. I have an
application which takes input only from such a beast and I want to
be able to pump bits at it. And as has been pointed out in other
threads, a file socket is NOT the same thing as a file pipe.

Probably I just don't have the right jargon for it. Pardon my *X
ignorance. Just as the Unix creators thought it appropriate that
a program named "biff" would tell us that mail had arrived (because
the guy who wrote the program had a dog named Biff which barked at
the postman), we should probably JUST KNOW that something similar
exists in this case. How about a program called "cardiac-arrest"
for creating a "file socket", so named because cardiac arrest is
what can happen when you stick a real (ie steel) file into a real
(ie 120 volt) socket? (Hot side with your other hand on a pipe,
of course.) Or some such.

So, can anyone answer this question now?

Thanks,
Greybeard
 
Old 08-28-2007, 03:04 PM   #6
enigma82
Member
 
Registered: Sep 2004
Location: Fagaras, Romania
Distribution: Mandrake 10.0
Posts: 48

Original Poster
Rep: Reputation: 15
I even forgot that I posted this ! I kinda lost touch with Linux in a while so thanks for reminding me that this world still exists !

However, I remember that at that time I did not find any utility that could create a socket file and I ended up in reinstalling my box.
Now that you brought this back into my attention I have done a little search in the web and maybe this will help you a little:

http://www.thescripts.com/forum/thread691045.html

You have to write some code in order to create the socket file, but I really don't have any idea about how the code should look like since I know nothing about programming with gcc.

I really hope this will give you a clue and I'm really sorry for not being able to provide more consistent information.


Regards,
 
Old 08-24-2009, 07:28 AM   #7
JLarky
LQ Newbie
 
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by enigma82 View Post
I have a problem: I accidentally erased my socket file in mysql. Anybody knows how I can create that file back? I tried copying a socket file from another location and renaming it but it didn't work.
Code:
mkfio /path/to/file
is it?
 
Old 11-09-2009, 08:20 PM   #8
arbitraryantonym
LQ Newbie
 
Registered: Nov 2009
Posts: 10

Rep: Reputation: 0
mysql.sock is a fifo file. It is essentially a bidirectional pipe "|" that exists as a file so that processes can talk to eachother without going to all the trouble of using network sockets.

see the options for mkfifo. on my system the file is:

srwxrwxrwx mysql mysql

Also note that you should double check /etc/services and make sure mysql is listed in there (default port 3306).
 
Old 06-28-2011, 08:59 PM   #9
dlthomas
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Rep: Reputation: Disabled
Lots of misunderstanding here; let's see if I can clarify.

A socket file is not a regular file, it's more like an IP address (it is also not a fifo, although those are similar). A socket file is created by the system when a program calls bind on a unix domain socket, which is a special kind of network socket that can only be internal to one computer. The system then associates this special file with the socket file descriptor that the program bound (or more specifically, the "inode" to which that file descriptor refers).

From that point on, the program that created the socket has no interaction with the socket by the filename. If you move it elsewhere, create new links to it, or remove it, you may confuse other programs that are trying to talk to the program in question, but the program itself won't see it at all. You are only changing the set of names that point at that inode (and you can connect to the listening program at that new name!). Thinking of the filename as a domain name, the inode as the ip address, and the filesystem as DNS isn't so very far off.

So considering, in this case, mysqld and it's socket. As should be apparent (I hope) from the above, copying a socket file created by some other program to /var/run/mysql.sock isn't going to help re-establish communication with the mysql server - you've just pointed the filename you want at a different inode, and it will mean that other program (if it is still alive) will be receiving the connections that should be going to mysqld; not what we want at all. What is needed is for mysqld itself to recreate the socket.

So, how can we make it do that? Per http://www.pathname.com/fhs/pub/fhs-2.3.html, the /var/run filesystem is the place for run-time variable data and should be cleared out at each boot. So a restart of the computer should do it. But that's ugly. We should be able to just restart the service (it would be even nicer if a reload would do it, but I've tested and it doesn't). So ideally, the init scripts should handle this and on the version of ubuntu I'm in front of they do. Here,

sudo service mysql restart

works just fine after removing /var/run/mysql.sock, and the file is recreated. If that doesn't work, you can try running the init scripts manually with something like

sudo /etc/init.d/mysqld restart

If that still doesn't work, then you need to bring it down some other way. Per http://dev.mysql.com/doc/refman/5.0/...-response.html we see that a TERM signal will safely shut down the server, so we can say

ps -A | grep mysqld

to get the pid of the running server (as mysqld is not so well behaved as to provide us with a pid file, but no biggie), and then (replacing 12345 with the pid we found):

sudo kill -TERM 12345

So now mysqld should have shut itself down, and you can bring it back up the same way you started it in the first place. If the socket file still doesn't exist at that point, the server is probably failing to come up and you should check your log files (probably at /var/log/mysql/error.log) for reasons why.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to operate socket with file interface wangjinyi Programming 4 11-27-2005 11:31 PM
Redirecting socket output to a file elmafiacs Programming 1 10-15-2005 05:18 AM
what is a socket file?? augustus123 Linux - Distributions 3 12-06-2004 10:41 PM
How to create socket ? karl123 Linux - Hardware 1 05-31-2004 04:50 AM
Unix socket programming - how to sent a file Scrag Programming 9 03-28-2004 09:54 PM


All times are GMT -5. The time now is 10:54 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration