open-eats / OpenEats

:pizza: Self Hosted Recipe Management App :hamburger:
https://open-eats.github.io/
MIT License
669 stars 102 forks source link

When using remote DB openeats manage.py fails with pretty much everything due to not using Password... #145

Closed ekakela closed 3 years ago

ekakela commented 3 years ago

Hi,

Noticed that manage.py is hitting a lot of errors when executing pretty much anything and login does not work either.

I have following in the env_prod.yml ofcourse with actual values and the mysql user has been created with openeats@'%' and is able to login during the quick-start.py but after that if fails

Database config

MYSQL_DATABASE=openeats MYSQL_USER=openeats MYSQL_PASSWORD= MYSQL_HOST=db.domain.tld

I have also tested adding manually .my.cnf to the api container volume without success as it does not seem to respect it.

Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/usr/local/lib/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.6/site-packages/django/core/management/init.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv self.execute(args, cmd_options) File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 352, in execute self.check_migrations() File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 442, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in init self.loader = MigrationLoader(self.connection) File "/usr/local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in init self.build_graph() File "/usr/local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 212, in build_graph self.applied_migrations = recorder.applied_migrations() File "/usr/local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 61, in applied_migrations if self.has_table(): File "/usr/local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 44, in has_table return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()) File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 255, in cursor return self._cursor() File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 232, in _cursor self.ensure_connection() File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection self.connect() File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 89, in exit raise dj_exc_value.with_traceback(traceback) from exc_value File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection self.connect() File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect self.connection = self.get_new_connection(conn_params) File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 227, in get_new_connection return Database.connect(conn_params) File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 86, in Connect return Connection(args, *kwargs) File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 204, in init super(Connection, self).init(args, **kwargs2) django.db.utils.OperationalError: (1045, "Access denied for user 'openeats'@'172.18.0.4' (using password: NO)")

ekakela commented 3 years ago

Managed to get this working after a bit of digging in the settings.py

It seems that despite using another user and MYSQL_PASSWORD for most, the manage.py still depends on MYSQL_ROOT_PASSWORD so changed my env_prod.yml to have both MYSQL_PASSWORD and MYSQL_ROOT_PASSWORD for the the user I am using for external DB