Changing the root password of a MySQL
If its a new installation we recommend you to run the following command in your terminal
# mysql_secure_installation
If you just want to change the root password you can do this by the following method.
# mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> set password for 'root'@'localhost' = PASSWORD('MyNewPassword');
mysql> FLUSH PRIVILEGES;
mysql> exit;
# service mysql restart
Remember as shown above to restart the mysql, by either using service or “systemctl restart mysql”