Most probably its happens forgetting password is one thing, in case if you forgot the MySQL root password we can reset it using the steps as below,

To reset the MySQL root password, stop the MySQL server if its already running, you can use any one command as below,

$ sudo service mysql stop
$ sudo /etc/init.d/mysql stop
$ sudo systemctl stop mysql.service

Create a directory mysqld in /var/run and give mysql user access to it.

$ sudo mkdir /var/run/mysqld/
$ sudo chown mysql /var/run/mysqld/

Then, execute the command as below to start MySQL in safe mode by bypassing the standard authentication process..

$sudo mysqld_safe --skip-grant-tables &

Execute the command to enter into mysql root account without typing a password,

$ mysql -u root

Once logged into the database, execute the command statement below, switch to mysql database and run the command,

> use mysql;

mysql> UPDATE USER SET authentication_string=PASSWORD("root") WHERE User='your_password';
Query OK, 4 rows affected, 1 warning (0.02 sec)
Rows matched: 4  Changed: 4  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit;

Then, you have to stop the service and start it again,

$ sudo systemctl stop mysql.service
$ sudo systemctl start mysql.service

I hope so, you should be able to login to MySQL database using root user with new password.

$ sudo mysql -u root -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.24-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW VARIABLES LIKE 'validate_password%';
Empty set (0.00 sec)