Score:-1

Mysql error "'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)'" and I can't reset root password either

gy flag

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...

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/
NotTheDr01ds avatar
vn flag
Any progress? Does `sudo mysql` get you to a prompt without the server? If so, try [this answer](https://askubuntu.com/a/1133325/1165986) to reset the root password.
coniferous avatar
gy flag
I finally got it to work. I removed mysql all over again and reinstalled. I was having trouble resetting the password for root, but I eventually got it. I think part of the issue may have been that I just didn't know that you have to use `sudo` when logging in as root... @NotTheDr01ds
NotTheDr01ds avatar
vn flag
Cool - And yes, I believe (IIRC) that's because the *local* database file is owned by root. So until the server is running, accessing/modifying the local file will require `sudo`.
白玄玉 avatar
om flag
you can try `sudo chmod 777 -R /var/run/mysqld/`
Score:0
in flag
  1. Stop MySQL (sudo systemctl stop mysql)
  2. Verify process is stopped
  3. Start MySQL with --skip-grant-tables

Alternativly purge mysql: sudo apt purge mariadb-server mysql-common Verify /etc/mysql and /var/lib/mysql are empty/ deleted

Reinstall

coniferous avatar
gy flag
I can't run systemctl because I'm in WSL and I've done all of that already
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.