pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'172.19.0.6' (using password: YES)")
See original GitHub issueDescription of the issue
My issue is similar to this one, although on production (that issue is over a year old, didn’t want to necro open it, and it was noted to open new issue for production; also, not using bench, as this is production so, not all is relevant; although I did try some of the solutions there, without success ): https://github.com/frappe/frappe_docker/issues/239
Context information (for bug reports)
Steps to reproduce the issue
- After what appeared to be a successful setup of Docker et al, following the Docker installation instructions
- Get to the point of starting things up by running the following command:
docker exec -it \
-e "SITE_NAME=$SITE_NAME" \
-e "DB_ROOT_USER=$DB_ROOT_USER" \
-e "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" \
-e "ADMIN_PASSWORD=$ADMIN_PASSWORD" \
-e "INSTALL_APPS=erpnext" \
mysitecom_erpnext-python_1 docker-entrypoint.sh new
Observed result
Access denied for user roor error:
pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'172.19.0.6' (using password: YES)")
Expected result
Expected root to have access to mariadb
Stacktrace / full error message if available
docker exec -it \
-e "SITE_NAME=$SITE_NAME" \
-e "DB_ROOT_USER=$DB_ROOT_USER" \
-e "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" \
-e "ADMIN_PASSWORD=$ADMIN_PASSWORD" \
-e "INSTALL_APPS=erpnext" \
mysitecom_erpnext-python_1 docker-entrypoint.sh new
Attempt 1 to connect to mariadb:3306
Attempt 1 to connect to redis-queue:6379
Attempt 1 to connect to redis-cache:6379
Attempt 1 to connect to redis-socketio:6379
Connections OK
Traceback (most recent call last):
File "/home/frappe/frappe-bench/commands/new.py", line 118, in <module>
main()
File "/home/frappe/frappe-bench/commands/new.py", line 70, in main
db_port=db_port,
File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 72, in _new_site
no_mariadb_socket=no_mariadb_socket,
File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 106, in install_db
setup_database(force, source_sql, verbose, no_mariadb_socket)
File "/home/frappe/frappe-bench/apps/frappe/frappe/database/__init__.py", line 16, in setup_database
return frappe.database.mariadb.setup_db.setup_database(force, source_sql, verbose, no_mariadb_socket=no_mariadb_socket)
File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/setup_db.py", line 39, in setup_database
if force or (db_name not in dbman.get_database_list()):
File "/home/frappe/frappe-bench/apps/frappe/frappe/database/db_manager.py", line 60, in get_database_list
return [d[0] for d in self.db.sql("SHOW DATABASES")]
File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 121, in sql
self.connect()
File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 74, in connect
self._conn = self.get_connection()
File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 90, in get_connection
local_infile = frappe.conf.local_infile)
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py", line 325, in __init__
self.connect()
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py", line 599, in connect
self._request_authentication()
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py", line 861, in _request_authentication
auth_packet = self._read_packet()
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py", line 684, in _read_packet
packet.check_error()
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/protocol.py", line 220, in check_error
err.raise_mysql_exception(self._data)
File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'172.19.0.6' (using password: YES)")
Note: I’m able to access maria db like so: docker exec -ti mysitecom_mariadb_1 bash
and then mysql -u root -p
and enter the root password set in .env to access the DBs:
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| _123-redacted-123 |
| information_schema |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.001 sec)
Does the following look correct? Should root have more host access than localhost?
MariaDB [(none)]> SELECT user,authentication_string,plugin,host FROM mysql.user;
+-------------------+-----------------------+--------+------------+
| user | authentication_string | plugin | host |
+-------------------+-----------------------+--------+------------+
| root | | | localhost |
| _38f74ec15f7433a1 | | | 172.19.0.4 |
| _38f74ec15f7433a1 | | | % |
+-------------------+-----------------------+--------+------------+
3 rows in set (0.000 sec)
Any direction would be greatly appreciated, thanks!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:39 (1 by maintainers)
Top GitHub Comments
The issue still exists. Local docker (swarm), using env.local, all volumes clean, mysql/mariadb root user name is ‘root’, all other components get deployed (not using traefik), site-creator fails when deployed from within docker-compose.yml because its unable to connect to the db - error is ‘access denied for user ‘root’, using password: yes’
However - the error seems to happen when site-creator is deployed from within the docker-compose.yml file - using ‘docker run’ from the command line works…!
Workaround that got the installation done for me:
In the above command, NW_NAME should be the same you specified in step 1 and in docker-compose.
Basic principles behind the workaround:
Hope that helps.
Found the issue! When following the single bench install instructions, the
DB_ROOT_USER
variable must remain on the default value ofroot
in the.env
file. This is because the mariadb image does not support changing the root username, and docker-compose.yml consequently does not set MariaDB’s root username to theDB_ROOT_USER
value.After deleting all of my volumes (with
docker volume prune
) and starting over withDB_ROOT_USER=root
in.env
, ERPNext is successfully installed.