It’s been a while and today I was stuck on an older machine trying to upgrade a broken mysql update.
I had this error during the
sudo apt upgrade command:
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server
After trying different solutions posted on StackOverflow, I was able to fix it with this combination of commands: