I'm getting the following error for a couple of commands I'm trying to run AND I don't know the password whenever I'm prompted for that. (note: I just updated my ubuntu distribution to 22.04, but I previously didn't have a password set/had an empty password for 'root').
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)'
It seems from most posts that the common issue is that mysql-server isn't actually running.I can see that mine is running, though, with sudo service mysql status
and the following commands return...
$ cat /etc/services | grep 3306 mysql 3306/tcp$ netstat -tulpn | grep 3306 (No info could be read for "-p": geteuid()=1000 but you should be root.) tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:33060 0.0.0.0:* LISTEN
These commands are giving the "Can't connect..." error:
- mysqladmin -u root -p shutdown
- mysqladmin version
- mysql
- mysql -u root
- mysql -u root -h localhost -p
Running mysql -u root -h 127.0.0.1 -p
seems to work in that it prompts me for a password, but none of my prior passwords are working and I have not been able to run sudo mysqld_safe --skip-grant-tables &
or sudo mysqld_safe --skip-grant-tables --skip-networking &
successfully to reset the root password.
I have also run...
- sudo apt-get install --reinstall mysql-server
- sudo apt update
- sudo apt upgrade
- sudo apt install mysql-server
- sudo apt install mysql-client
- sudo usermod -d /var/lib/mysql/ mysql
- sudo dpkg --configure -a
- and followed the recommendations from the top two answers on this post: https://stackoverflow.com/questions/41984956/cant-reset-root-password-with-skip-grant-tables-on-ubuntu-16
- and tried to uninstall MySQL by following directions here
- and tried to back up the sock folder and restore it as advised here
Additional random info:
I also know that /var/run/mysqld/mysqld.sock
did exist earlier in this process (I only have mysql.bak in that directory now), but when I run sudo find / -type s
, it just returns a bunch of files/directories with "Permission Denied" (I assume because I'm in WSL), so I haven't checked that there could be another mysql.sock somewhere.
I also know that /etc/mysql/my.cnf
is just pointing to -> /etc/alternatives/my.cnf
, which only has the following in it (other than some comments):
!includedir /etc/mysql/conf.d/!includedir /etc/mysql/mysql.conf.d/