Cannot login to MySQL database after fresh install with root ID and empty/no password like other older MySQL versions do
As of Ubuntu 20.04 with MySql 8.0 : you can set the password that way:
login to mysql with sudo mysql -u root
change the password:
USE mysql; UPDATE user set authentication_string=NULL where User='root'; FLUSH privileges; ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'My-N7w_And.5ecure-P@s5w0rd'; FLUSH privileges; QUIT
now you should be able to login with mysql -u root -p
(or to phpMyAdmin with username root) and your chosen password.
P,S:
You can also login with user debian-sys-maint
, the password is written in the file /etc/mysql/debian.cnf