Bench --site erpnext-site --force reinstall generate this error :pymysql.err.OperationalError: (1045, "Access denied for user 'my-user'@'localhost' (using password: YES)")

frappe-bench$ bench --site erpnext-site --force reinstall
WARN: bench is installed in editable mode!

This is not the recommended mode of installation for production. Instead, install the package from PyPI with: pip install frappe-bench

This will wipe your database. Are you sure you want to reinstall? [y/N]: y
Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
main()
File “/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/commands/site.py”, line 133, in reinstall
_reinstall(site, admin_password, yes, verbose=context.verbose)
File “/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/commands/site.py”, line 153, in _reinstall
install_apps=installed, admin_password=admin_password)
File “/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/commands/site.py”, line 65, in _new_site
admin_password=admin_password, verbose=verbose, source_sql=source_sql,force=force, reinstall=reinstall)
File “/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/installer.py”, line 31, in install_db
dbman.create_database(db_name)
File “/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/model/db_schema.py”, line 525, in create_database
if target in self.get_database_list():
File “/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/model/db_schema.py”, line 554, in get_database_list
return [d[0] for d in self.db.sql(“SHOW DATABASES”)]
File “/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/database.py”, line 136, in sql
self.connect()
File “/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/database.py”, line 86, in connect
charset=‘utf8mb4’, use_unicode = True, conv = conversions)
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/init.py”, line 94, in Connect
return Connection(*args, **kwargs)
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 327, in init
self.connect()
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 598, in connect
self._request_authentication()
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 862, in _request_authentication
auth_packet = self._process_auth(plugin_name, auth_packet)
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 933, in _process_auth
pkt = self._read_packet()
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 683, in _read_packet
packet.check_error()
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/erpnext/erpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, “Access denied for user ‘my-user’@‘localhost’ (using password: YES)”)

i tried the following :
sudo nano/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 user where user = 'my-user; `

  • 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 = ‘my-user’ and host = ‘localhost’;

UPDATE mysql.user set Password = PASSWORD(’ your-pass’) where user = ‘my-user’ and host = ‘localhost’;

  • Use the proper password column from above
    UPDATE mysql.user set Password = PASSWORD(‘your-pass’) where user = ‘my-user’ and host = ‘localhost’;

SELECT User, Host, plugin FROM user;

–note: If Plugin is not mysql_native_password, then set the plugin by the below command

UPDATE user SET plugin=‘mysql_native_password’ WHERE User=‘my-user’;

FLUSH PRIVILEGES;
exit;

Remove the skip-grant-tables from /etc/mysql/my.cnf, restart the service.

but it did not work!
so i need to delete any previously database and all related configuration for any created site.
its ok there is nothing important to loose.