Working on a Ubuntu 22.04 system with MySQL 8. I have a legacy collection of MySQL data/dbs on an external harddrive that I used a Docker container and MySQL image to connect to and export. This worked fine, but when I attempt to connect to my existing MySQL installation via command line I'm getting the following error despite the server showing as 'active' via systemctl
:
chris@chris-X1C6:~$ mysql -u admin -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I've googled and found a few (and this) remedies, none of which fix the issue. System restart doesn't address either.
As a first common sense check, I don't see a mysql sock file in the /tmp
location referenced, but do see one (mysqld.sock
) located in the /var/run/mysqld
directory. I also don't see a .cnf file to inspect in the mysql directory (/var/lib/mysql
).
What else should I be looking at?
ps ax | grep mysql
). looks like you can use the--socket
option, theMYSQL_UNIX_PORT
environment variable, or various.cnf
files to getmysql
to check a different socket path. Since the command looks like it's checking a non-default path, maybe docker or some other process updated that env?/var/run/mysqld/mysqld.sock
. The mysql command error says it's checking for/tmp/mysql.sock
, so I'm curious ifset | grep MYSQL
shows something unexpected. You might just need to link it likeln -s /private/var/mysql/mysql.sock /tmp/mysql.sock
like in the answer here: stackoverflow.com/a/18418296/7411885 there are some other good troubleshooting steps in there as wellset...
call. I theorize Docker changed some default directory where the sock file is being referenced (ie, from default/var/run...
to the/tmp
location)...nothing turned up doing afind
for the location, do you know where the socket directory is specified in some mysql config file so I can change it back to where it actually exists?