frappe_docker: pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'172.19.0.6' (using password: YES)")
Description 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!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 41 (1 by maintainers)
Found the issue! When following the single bench install instructions, the
DB_ROOT_USERvariable must remain on the default value ofrootin the.envfile. 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_USERvalue.After deleting all of my volumes (with
docker volume prune) and starting over withDB_ROOT_USER=rootin.env, ERPNext is successfully installed.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.
I had the same problem when I tried to install Frappe from docker-compose. Changing the environment simply using MARIADB_ROOT_PASSWORD instead of the MYSQL_ROOT_PASSWORD did the trick for me.
db: image: mariadb:10.7.8 healthcheck: test: mysqladmin ping -h localhost --password=admin interval: 1s retries: 15 deploy: restart_policy: condition: on-failure command: - --character-set-server=utf8mb4 - --collation-server=utf8mb4_unicode_ci - --skip-character-set-client-handshake - --skip-innodb-read-only-compressed # Temporary fix for MariaDB 10.6 environment: MARIADB_ROOT_PASSWORD: "admin" # MYSQL_ROOT_PASSWORD: "admin" # MYSQL_ROOT_HOST: "%" volumes: - db-data:/var/lib/mysqlI made similar experiences as @jreduar. Either the password changed or the host ip changed. Inside the Frappe-bench container:
mysql -h mariadb -u root -prootpass mysqlselect * from user;to identify user names.ALTER USER 'username'@'%' IDENTIFIED BY 'newpass';, eg.ALTER USER '_ab9080ba42f22828'@'%' IDENTIFIED BY 'password_from_site_config.json';CREATE USER '_ab9080ba42f22828'@'%' IDENTIFIED BY 'password_from_site_config.json';DROP USER '_ab9080ba42f22828'@'172.20.0.4';GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';, eg.GRANT ALL PRIVILEGES ON _41da75e60133e6ed.* TO '_41da75e60133e6ed'@'%';I found the following, when the setup is done, the mariaDB user is set to another Host (or maybe change while build) and its rejected when the main container wants interact, so I had done the following to make it work:
Hope this helps
@revant can the issue be reopened as it seems it’s confirmed to still exist?
no news on this? The provided docker-compose file should be able to reproduce the issue.
I was also having this issue, and managed to track it down to the fact that WSL reads files in Windows as having global permissions (
-rwxrwxrwx), so if you are using Docker Desktop on Windows 10, this might be a solution.Upon booting, the mariadb container gives the following message:
So what I did was:
docker volume prune, since it was a clean install and I had no data to keep (it might not be needed);cdto the path where you cloned the repo andcd installation+chmod a-wx frappe-mariadb.cnf(I have not tested other permission combinations);docker-compose --project-name <project-name> up -dagain.If the warning isn’t present on the mariadb container logs, it should now work normally.