Frappe_docker with external DB (AWS RDS MariaDB)

Hi i have a fresh installation of frappe_docker on AWS EC2 using docker .
I changed the entries in .env
MARIADB_HOST=erpnext.cns0yhnpi9hx.ap-south-1.rds.amazonaws.com

which is a extranl DB instance . When I try to run docker compose up
site creator throws error:
pymysql.err.OperationalError: (1044, “Access denied for user ‘root’@‘%’ to database ‘_69928f0f6369849a’”)

someone else also encountered the same error ??
I have already tried granting all permission to root … since this database ‘_69928f0f6369849a’ is created later on during the initialization is there a way to automatically grant permission to root user for this ‘_69928f0f6369849a’ database ?.

for AWS RDS you need special configuration and they don’t allow root user to login, create an admin user in RDS separately.

check this entry Using Frappe with Amazon RDS (or any other DBaaS) · frappe/frappe Wiki · GitHub

1 Like

I go through the above process .
where while setting up AWS RDS
there was no option for “create a parameter group” netigher during modify

character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
default-character-set = utf8mb4

So here is what I did

docker ps
docker exec -it frappe_docker_erpnext-schedule_1 /bin/bash
rm -rf mysite.localhost
delete the already existing db by the name ‘_69928f0f6369849a’
bench new-site mysite.localhost --no-mariadb-socket

frappe@16388c7d73d6:~/frappe-bench/sites$ rm -rf mysite.localhost

frappe@16388c7d73d6:~/frappe-bench/sites$ ls -ltr
total 16
drwxr-xr-x 2 root root 4096 Dec 11 15:11 assets
-rw-r–r-- 1 frappe frappe 15 Dec 11 15:11 apps.txt
-rw-r–r-- 1 frappe frappe 274 Dec 11 15:11 common_site_config.json
-rw-r–r-- 1 frappe frappe 174 Dec 11 15:11 app_versions.json
frappe@16388c7d73d6:~/frappe-bench/sites$ bench new-site mysite.localhost --no-mariadb-socket
MySQL root password:
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 101, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py”, line 555, in invoke
return callback(*args, *kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 41, in new_site
db_port=db_port, new_site=True)
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 55, in setup_database
dbman.grant_all_privileges(db_name, db_name)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/db_manager.py”, line 53, in grant_all_privileges
self.db.sql("GRANT ALL PRIVILEGES ON %s.
TO ‘%s’@‘%s’;" % (target, user, host))
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py”, line 152, in sql
self._cursor.execute(query)
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py”, line 517, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py”, line 732, in _read_query_result
result.read()
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py”, line 1075, in read
first_packet = self.connection._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: (1044, “Access denied for user ‘root’@‘%’ to database ‘_69928f0f6369849a’”)
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 18, in
[sys.executable, bench_helper, ‘frappe’] + sys.argv[1:],
File “/usr/local/lib/python3.7/subprocess.py”, line 363, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[’/home/frappe/frappe-bench/env/bin/python’, ‘/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’, ‘frappe’, ‘new-site’, ‘mysite.localhost’, ‘–no-mariadb-socket’]’ returned non-zero exit status 1.
frappe@16388c7d73d6:~/frappe-bench/sites$ exit
exit

try

bench new-site --help

pass the non root user as --mariadb-root-user to new-site command.

Used bench new-site

bench new-site mysite.localhost --mariadb-root-username _69928f0f6369849a --mariadb-root-password XXX

same thing

raise errorclass(errno, errval)

pymysql.err.OperationalError: (1045, “Access denied for user ‘_69928f0f6369849a’@‘84.212.145.123’ (using password: YES)”)

I also tried creating another super user :slight_smile:

and now stuck with
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.InternalError: (1049, “Unknown database ‘admin’”)

I added priviliges to root to this db ‘_69928f0f6369849a’ but now I am stuck with

raise Exception(“Database %s already exists” % (db_name,))

File “/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/setup_db.py”, line 45, in setup_database
raise Exception(“Database %s already exists” % (db_name,))
Exception: Database _69928f0f6369849a already exists
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 18, in
[sys.executable, bench_helper, ‘frappe’] + sys.argv[1:],
File “/usr/local/lib/python3.7/subprocess.py”, line 363, in check_call
raise CalledProcessError(retcode, cmd)

bench new-site --force overwrites the db while creating new site. Try it.

1 Like