How to change MySQL root password in Debian / Ubuntu

Connect to MySQL Server using Linux terminal:

sudo mysql --user=root mysql

Run the following commands:

UPDATE mysql.user SET authentication_string=null WHERE User='root';
flush privileges;

Replace NEW_PASSWORD with your own.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NEW_PASSWORD';
flush privileges;
exit;