Change root password

Start mysql without user permission check:

/etc/init.d/mysql stop; mysqld_safe --skip-grant-tables &

Which allow tp access mysql-cli with root user without password even with no user:

mysql -u root

Then, create root user and grant him all privileges :

use mysql;
flush privileges;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password';
quit

Finally, restart MySQL in standard mode :

/etc/init.d/mysql stop; /etc/init.d/mysql start

MySQL 5.7

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';

Source for an explaination