1

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/

2 Answers2

0
  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

Uwe Burger
  • 642
  • 3
  • 3
0

When you want to search for a something you would use something like this:

find / -type f -name "mysql*.*" 

because you need to specify a name option.

But mysql was replaced with mariadb quite a while ago. Even though you use the same commands.

if it still lets you ask for a password after executing

sudo /etc/init.d/mysql stop

You need to stop mariadb

sudo systemctl stop mariadb
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
sudo mysql -u root
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
FLUSH PRIVILEGES;
exit

then reset it

sudo systemctl stop mariadb

sudo systemctl start mariadb