I used this solution
extracted from Guide: Manual Install ERPNext on Ubuntu 17.xx & 18.xx - #3 by Parag_Kapoor
Parag_Kapoor
May '18
Database Login Issues
In some cases Database may not login, to rectify the issue Please Follow below steps
sudo vim /etc/mysql/my.cnf
Add the following lines at the end:
[mysqld]
skip-grant-tables
Then Restart the service
sudo service mysql restart
Login to Mysql & follow the command
mysql -u root
use mysql
select * from mysql where user = ‘root’; - Look at the top to determine whether the password column is called password or authentication_string
UPDATE mysql.user set password_field from above = PASSWORD(‘your_new_password’) where user = ‘root’ and host = ‘localhost’; - Use the proper password column from above
SELECT User, Host, plugin FROM user;
If Plugin is not mysql_native_password, then set the plugin by the below command
UPDATE user SET plugin=‘mysql_native_password’ WHERE User=‘root’;
FLUSH PRIVILEGES;
exit;
Remove the skip-grant-tables from /etc/mysql/my.cnf, restart the service & it’s Done