DB error pymysql.err.OperationalError: (1044, "Access denied for user 'root'@'localhost' to database '_8ec4e1591446703e'")

I have this error when i execute : bench new-site testing.erp

pymysql.err.OperationalError: (1044, "Access denied for user 'root'@'localhost' to database '_8ec4e1591446703e'")

#IF this happens....
#ERROR 1045 (28000): Access denied for user '_8ec4e1591446703e'@'localhost' (using password: YES)
DBname=$(cat ~/frappe-bench/sites/testing.erp/site_config.json | awk '/db_name/ {print $2}' | sed "s/\"//g" | sed "s/,//g")
DBpass=$(cat ~/frappe-bench/sites/testing.erp/site_config.json | awk '/db_password/ {print $2}' | sed "s/\"//g")
#
mysql -uroot -pYourMYSQLpassword -Bse "GRANT ALL PRIVILEGES ON *.* TO '$DBname'@'localhost' IDENTIFIED BY '$DBpass' WITH GRANT OPTION;"
mysql -uroot -pYourMYSQLpassword -Bse "GRANT ALL PRIVILEGES ON *.* TO '$DBname'@'127.0.0.1' IDENTIFIED BY '$DBpass' WITH GRANT OPTION;"
#
mysql -uroot -pYourMYSQLpassword -Bse "set password for '$DBname'@'localhost' = password('$DBpass');"
mysql -uroot -pYourMYSQLpassword -Bse "set password for '$DBname'@'127.0.0.1' = password('$DBpass');"
#delete the DB and re-run
bench new-site testing.erp
1 Like