sudo service mysql stop
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
mysql -u root
FLUSH PRIVILEGES;
USE mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Secret#123';
# For older mysql
# UPDATE user SET authentication_string=PASSWORD("Secret#123") WHERE User='root';
UPDATE user SET plugin="mysql_native_password" WHERE User='root';
quit
sudo pkill mysqld
sudo service mysql start
Source: https://linuxconfig.org/how-to-reset-root-mysql-password-on-ubuntu-18-04-bionic-beaver-linux