pymysql.err.OperationalError - (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

I install ERPNext in Vultr(Ubuntu). i face the belo error msg.

root@Frappe:/opt/bench/erpnext# bench --site teachable.digital --force reinstall
This will wipe your database. Are you sure you want to reinstall? [y/N]: y
MySQL root password:
Traceback (most recent call last):
File “/usr/lib/python3.8/runpy.py”, line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File “/usr/lib/python3.8/runpy.py”, line 87, in _run_code
exec(code, run_globals)
File “/opt/bench/erpnext/apps/frappe/frappe/utils/bench_helper.py”, line 104, in
main()
File “/opt/bench/erpnext/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/click/core.py”, line 829, in call
return self.main(*args, **kwargs)
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/click/core.py”, line 782, in main
rv = self.invoke(ctx)
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/click/core.py”, line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/click/core.py”, line 610, in invoke
return callback(*args, **kwargs)
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/click/decorators.py”, line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File “/opt/bench/erpnext/apps/frappe/frappe/commands/init.py”, line 26, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/opt/bench/erpnext/apps/frappe/frappe/commands/site.py”, line 300, in reinstall
_reinstall(site, admin_password, mariadb_root_username, mariadb_root_password, yes, verbose=context.verbose)
File “/opt/bench/erpnext/apps/frappe/frappe/commands/site.py”, line 321, in _reinstall
_new_site(frappe.conf.db_name, site, verbose=verbose, force=True, reinstall=True, install_apps=installed,
File “/opt/bench/erpnext/apps/frappe/frappe/installer.py”, line 62, in _new_site
install_db(
File “/opt/bench/erpnext/apps/frappe/frappe/installer.py”, line 109, in install_db
setup_database(force, source_sql, verbose, no_mariadb_socket)
File “/opt/bench/erpnext/apps/frappe/frappe/database/init.py”, line 14, in setup_database
return frappe.database.mariadb.setup_db.setup_database(force, source_sql, verbose, no_mariadb_socket=no_mariadb_socket)
File “/opt/bench/erpnext/apps/frappe/frappe/database/mariadb/setup_db.py”, line 42, in setup_database
dbman.delete_user(db_name, **dbman_kwargs)
File “/opt/bench/erpnext/apps/frappe/frappe/database/db_manager.py”, line 28, in delete_user
host = self.get_current_host()
File “/opt/bench/erpnext/apps/frappe/frappe/database/db_manager.py”, line 14, in get_current_host
return self.db.sql(“select user()”)[0][0].split(‘@’)[1]
File “/opt/bench/erpnext/apps/frappe/frappe/database/database.py”, line 124, in sql
self.connect()
File “/opt/bench/erpnext/apps/frappe/frappe/database/database.py”, line 72, in connect
self._conn = self.get_connection()
File “/opt/bench/erpnext/apps/frappe/frappe/database/mariadb/database.py”, line 74, in get_connection
conn = pymysql.connect(
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/pymysql/connections.py”, line 353, in init
self.connect()
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/pymysql/connections.py”, line 633, in connect
self._request_authentication()
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/pymysql/connections.py”, line 907, in _request_authentication
auth_packet = self._read_packet()
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/pymysql/connections.py”, line 725, in _read_packet
packet.raise_for_error()
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/pymysql/protocol.py”, line 221, in raise_for_error
err.raise_mysql_exception(self._data)
File “/opt/bench/erpnext/env/lib/python3.8/site-packages/pymysql/err.py”, line 143, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, “Access denied for user ‘root’@‘localhost’ (using password: YES)”)

login to mysql and run these commands

GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘your_password’ WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON . TO ‘root’@‘localhost’ IDENTIFIED BY ‘your_password’ WITH GRANT OPTION;

it solved the same issue at our end.

1 Like

Thank u

:+1: you are welcome.

I found the solution!

Once the MariaDB is secured, log in to the MariaDB console with the following command:

mysql -u root -p

After login, change the MariaDB authentication plugin with the following command:

MariaDB [(none)]>USE mysql; MariaDB [(none)]>UPDATE user SET plugin='mysql_native_password' WHERE User='root';

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES; 
MariaDB [(none)]> EXIT;

Details could be found here: How To Install ERPNext on Ubuntu 20.04 | RoseHosting

Follow Tutorial Number 1 - 8 here: Simply Installing ERPNext in Ubuntu 20.04 | by Anastes Mp | Medium

And then follow Tutorial Number 4 here: How To Install ERPNext on Ubuntu 20.04 | RoseHosting

And then continiu with Tutorial Number 9 and so on here: Simply Installing ERPNext in Ubuntu 20.04 | by Anastes Mp | Medium

Hi, I’m having a syntax error. I doubled check it and re-entry, am I missing something?

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'r00tp@ss' WITH GRANT OPTION;

2 Likes

Wow! Thank you so much for the quick response. Apology, I’m a newbie in mySQL.