Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to locate the unix socket of a particular process

For a local MySQL connection, how would I find the unix socket number of the location connection? I don’t believe it’s in the ps command:

USER           PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
_mysql         141   0.0  0.0 34786180   3284   ??  Ss    6Jan22  16:21.85 /usr/local/mysql/bin/mysqld...

Is there a simpler way to find that?

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Here is an example of viewing the process(es) that have a given file open:

$ lsof /tmp/mysql.sock

COMMAND PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
mysqld  829 bkarwin   21u  unix 0x1c2b10907d83adad      0t0      /tmp/mysql.sock

Or go the other way, listing all files open for the process id of mysqld:

$ lsof -p 829

COMMAND PID    USER   FD     TYPE             DEVICE  SIZE/OFF                NODE NAME
...
mysqld  829 bkarwin   21u    unix 0x1c2b10907d83adad       0t0                     /tmp/mysql.sock
...

If you don’t know the process id, you can make lsof search for a process whose command starts with a given string:

$ lsof -c mysqld
(same output as for -p)

Read https://ss64.com/osx/lsof.html for more usage.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading