Resetting mysql root password

I need to reset my root mysql password. I am following the instructions found here: https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password.
When I issue the mysqld_safe command, I get this error: mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
I am running Ubuntu 24.04.

mysqld_safe is complaining because the runtime socket folder isn’t there.

Just recreate it and give it to the mysql user, then rerun the command.

# stop MySQL first
sudo systemctl stop mysql

# make the socket directory that vanished
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld   # ownership is important

# now start the server without grants so you can reset the password
sudo mysqld_safe --skip-grant-tables --skip-networking &

From there you can connect (mysql -u root) and run the usual

ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘new_password’;,

then kill the temporary server and sudo systemctl start mysql normally.

That’s all the DigitalOcean guide was missing on some systems the

/var/run/mysqld directory gets cleaned up when MySQL stops, so you have

to recreate it by hand before launching mysqld_safe.