# 1. stop mysqld service
# after this command, remember to double check if /var/run/mysqld folder exists and its owner is mysql:mysql
sudo /etc/init.d/mysql stop
# might have to do this
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
# 2. start mysql without password
sudo mysqld_safe --skip-grant-tables &
# 3. enter mysql console
mysql -uroot
use mysql; # use mysql table
update user set authentication_string=PASSWORD("") where User='root'; # update password to nothing
update user set plugin="mysql_native_password" where User='root'; # set password resolving to default mechanism for root user
flush privileges;
quit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start # reset mysql