open-eats / OpenEats

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

Access Denied - I think to DB #147

Open thewismit opened 3 years ago

thewismit commented 3 years ago

I hope the below helps. Let me know what else I can do to help you troubleshoot with me. Thank you!

/mnt/data/docker/OpenEats$ sudo docker-compose -f docker-prod.yml run --rm --entrypoint 'python manage.py createsuperuser' api
Creating openeats_api_run ... done
Traceback (most recent call last):
  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)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'172.22.0.4' (using password: YES)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    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/contrib/auth/management/commands/createsuperuser.py", line 59, in execute
    return super().execute(*args, **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 'root'@'172.22.0.4' (using password: YES)")

/mnt/data/docker/OpenEats$ ls -la
total 118
drwxrwxr-x  5 thewismit thewismit   22 Feb  2 11:38 .
drwxr-xr-x 14 thewismit root        18 Feb  2 11:31 ..
drwxrwxr-x  8 thewismit thewismit   13 Feb  2 11:31 .git
-rw-rw-r--  1 thewismit thewismit  312 Feb  2 11:31 .gitignore
-rw-rw-r--  1 thewismit thewismit 4826 Feb  2 11:31 CONTRIBUTING.md
-rw-rw-r--  1 thewismit thewismit 1085 Feb  2 11:31 LICENSE.md
-rw-rw-r--  1 thewismit thewismit  537 Feb  2 11:31 MAINTAINERS.md
-rw-rw-r--  1 thewismit thewismit 1583 Feb  2 11:31 README.md
-rw-rw-r--  1 thewismit thewismit   26 Feb  2 11:31 _config.yml
-rwxrwxr-x  1 thewismit thewismit 1364 Feb  2 11:31 commits.py
-rw-rw-r--  1 thewismit thewismit  692 Feb  2 11:31 docker-compose.yml
-rw-rw-r--  1 thewismit thewismit  167 Feb  2 11:34 docker-prod.override.yml
-rw-rw-r--  1 thewismit thewismit  170 Feb  2 11:38 docker-prod.version.yml
-rw-rw-r--  1 thewismit thewismit 1110 Feb  2 11:31 docker-prod.yml
-rw-rw-r--  1 thewismit thewismit 1102 Feb  2 11:31 docker-stage.yml
drwxrwxr-x  3 thewismit thewismit   12 Feb  2 11:31 docs
-rw-rw-r--  1 thewismit thewismit  535 Feb  2 11:31 env_dev.list
-rw-rw-r--  1 thewismit thewismit  421 Feb  2 11:36 env_prod.list
-rw-rw-r--  1 thewismit thewismit  553 Feb  2 11:31 env_stg.list
-rwxrwxr-x  1 thewismit thewismit 4629 Feb  2 11:31 quick-start.py
-rwxrwxr-x  1 thewismit thewismit 2472 Feb  2 11:31 release.py
drwxrwxr-x  2 thewismit thewismit    8 Feb  2 11:31 releases

/mnt/data/docker/OpenEats$ docker ps
CONTAINER ID   IMAGE                                 COMMAND                  CREATED         STATUS                   PORTS                                                                        NAMES
f4048beafd52   openeats/openeats-nginx:latest        "./start.sh"             4 minutes ago   Up 4 minutes             0.0.0.0:8003->80/tcp                                                         openeats_nginx_1
a8075ab5a333   openeats/openeats-api:latest          "/startup/prod-entry…"   5 minutes ago   Up 5 minutes                                                                                          openeats_api_1
5be01bec5d9e   mariadb:5.5.64                        "docker-entrypoint.s…"   5 minutes ago   Up 5 minutes (healthy)   3306/tcp                                                                     openeats_db_1
Drudoo commented 3 years ago

Can you try and enter your mariadb container (something like docker exec -it openeats_db_1 /bin/sh and run mysql -uroot -p<chosen password> and see if your container works?

rustymyers commented 3 years ago

Try starting over by removing the containers and volume: docker stop openeats_web_1 openeats_nginx_1 openeats_api_1 openeats_db_1 ; docker rm openeats_web_1 openeats_nginx_1 openeats_api_1 openeats_db_1 ; docker volume rm openeats_database

That should clean out the old database with a bad password (if that's the problem).

Then run the quick_start.py again. Follow this comment for initial setup: https://github.com/open-eats/OpenEats/issues/143#issuecomment-861570919