Changing Mysql root password in Ubuntu Server 20.04 after install

Posted under » MySQL » Ubuntu updated on 3 Oct 2020

I've just installed LAMP on Ubuntu 20.04. By default the root password for mysql is NULL. The idea is that you have to give a new password.

sudo mysql -u root

Enter the following sequence of SQL queries:

mysql> use mysql
mysql> flush privileges;
mysql> UPDATE user SET plugin='mysql_native_password',authentication_string=PASSWORD('LKY1smcmbab1') WHERE user = 'root';
mysql> exit

You should now able to connect to mysql as root or using phpmyadmin.

mysql -u root -p

Don't work? Maybe reread this older version of this.

web security linux ubuntu GIT svn Raspberry apache mysql php drupal cake symfony javascript Ajax css