Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find mysql.sock

I just had to re-install mysql and I am having a problem starting it up. It cannot find the socket (mysql.sock). The problem is that neither can I. In my Mac OS X 10.4 terminal, I type: locate mysql.sock, and I get back /private/tmp/mysql.sock. It makes sense that the socket file exist in that location, but it actually does not.

  1. How can I find the socket file?

  2. If locate is returning a false location, it must have some sort of memory and probably indexes. How can I refresh that index?

like image 302
Tony Avatar asked Apr 14 '09 16:04

Tony


People also ask

Where is my mysql sock?

The default location for the Unix socket file that the server uses for communication with local clients is /var/lib/mysql/mysql. sock.

Why mysql sock is missing?

sock is created by the mysql daemon on start, and it is removed (or, becomes un-connectable) if this daemon stops. This message is given by some client process, trying to connect your mysqld on this socket without success. Its most likely reason is that the mysqld doesn't run.

Where is mysql sock in Linux?

The MySQL server's socket file is named mysqld. sock and on Ubuntu systems it's usually stored in the /var/run/mysqld/ directory. This file is created by the MySQL service automatically.

How do I open mysql socks?

Check the Unix socket connection from the command line In the command line, run the following command: mysql -u root -p -S /var/run/mysqld/mysql. sock . Type a password for your root user and press Enter .


2 Answers

to answer the first part of your question:

run

% mysqladmin -p -u <user-name> variables 

and check the 'socket' variable

like image 183
behas Avatar answered Nov 07 '22 10:11

behas


This solved my problem

mysql_config --socket 

UPDATE

mysql_config can tell us where the file mysql.sock should be, but in my case the file didn't exist. So, I've deleted my.cnf:

sudo rm -rf /etc/my.cnf 

And then restarted mysql:

brew services restart mysql 

The file was created and mysql is now running well.

like image 40
Eugene Ramirez Avatar answered Nov 07 '22 11:11

Eugene Ramirez