Unfortunately, I had forgotten the root's password of MySQL.
Here, one of the methods is introduced, which works on my RasberryPi 3B+.
- Kill the process MySQL
sudo killall mysqld #or sudo /etc/init.d/mysql stop
- Start the mysqld with grant tables being skipped
MySQLd --skip-grant-tables &
- Login the mysql without password
mysql -u root
- Update the password and flush the privileges
MySQL> update MySQL.user set password=PASSWORD('newpassword') where User='root'; MySQL> flush privileges; MySQL> quit
- Restart the mysql
sudo /etc/init.d/mysql restart