Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have set up PHP and MySQL, however MySQL wants the mysql.sock file in /var/mysql, which is fair enough. I change the directory to /var/mysql however every time I restart my computer mysql.sock gets deleted and I can't work.

Has anyone got any ideas on how I can fix this problem?

share|improve this question

migrated from serverfault.com Nov 25 '11 at 13:14

This question came from our site for professional system and network administrators.

2  
Shouldn't mysql.sock be created automatically when the server starts? Have you made sure the MySQL server restarts automatically when you restart? –  Bruno Nov 25 '11 at 12:55
    
It would also be useful to say how you've installed MySQL: official installer, MacPorts, some MAMP bundles, ...? –  Bruno Nov 25 '11 at 12:59
    
Hey Richard, getting back to you: was your problem solved? If so, then please validate the answer by clicking the check next to it, so that future passers-by know they can use this method :) Otherwise, please leave a comment and add some details, so that we can figure out another way to help you! –  MattiSG Nov 29 '11 at 21:16
add comment

1 Answer 1

It is not ridiculous at all. I'd assume that, seeing you're coming from a Windows environment, you simply don't understand Unix sockets.

An Unix socket file is created when mysqld is started up, and mysql.sock is that file. It is a faster alternative to TCP/IP for use on a local system.

So yeah, it is actually totally normal that the file is deleted when you restart your computer: once the server is off, there's no reason for the communication line (socket) to still be open.

Your problem is not about the file missing, but about the server not starting up automatically on restart. You probably didn't have this problem “on Windows at work” not because of Windows, but because of work, where your workstation was set up to start MySQL server on boot.

Simply check the “Automatically Start MySQL Server on Startup” checkbox in the MySQL prefpane (in System Preferences) if you used the standard installer, or see the “MySQL does not start on startup” question in case of a problem on Lion or another installation method.

share|improve this answer
    
Ok, that makes sense, the problem now is the server won't even start since i've changed the location of where mysql.sock file is created, even with the "Automatically Start MySQL" check selected. However when I change the location back to /tmp/ folder low and behold it works again!!! But the web page with still try and look for the mysql.sock back in the /var/mysql/ directory. I've installed everything into Mac itself and not using any MAMP or other server programs to do this. Sorry for the very Amateur questions. –  user14141 Nov 25 '11 at 14:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.