On 07/15/2015 11:25 AM, Chris Angelico wrote:
On Thu, Jul 16, 2015 at 3:13 AM, Gary Roach <gary719_li...@verizon.net> wrote:
Every time I try to do a python manage.py migrate I get:
django.db.utils.OperationalError: FATAL: password
authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
DATABASES = {
'default': {
'USER': 'postgres',
'PASSWORD': 'xxxxxx', # A valid debian pw
}
}
PostgreSQL users are not the same as Unix users, and their passwords
aren't necessarily the same. I would recommend *not* using the
postgres user, which is the database superuser; instead, create a new
user explicitly. On most Debian PostgreSQL installations, you should
be able to invoke 'psql' while running as user 'postgres', either by
su'ing to postgres or with sudo, for instance:
$ sudo sudo -u postgres psql
That should get you into a database CLI as superuser. Your prompt
should look like this:
postgres=#
You should then be able to create a regular user, and grant
appropriate permissions:
postgres=# create user archives password 'traded-links-linguistics-informal';
CREATE ROLE
postgres=# grant all on database archivedb to archives;
GRANT
(Make sure you have the semicolons at the ends, otherwise you'll think
it's done nothing. It's actually waiting for you to type more lines
for the same command, but the prompt difference is so subtle that it's
easy to think it's silently ignoring you.)
Then you should be able to use user name 'archives' and password
'traded-links-linguistics-informal' (of course, you don't want to use
that; that's just what my password generating parrot came up with)
instead of 'postgres' and whatever the Unix password was.
Incidentally, I usually don't have any password on my postgres Unix
user, nor on the corresponding database users. Safer to use sudo, eg
to root and then down to postgres, as shown above.
ChrisA
I really appreciate the help Chris. I created a user archive with
password 'xxxxxx' and changed the settings.py file accordingly. When I
tried python manage.py migrate I got the following error with it's
traceback:
(archivedb)root@supercrunch:~/archivedb# python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 338, in execute_from_command_line
utility.execute()
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/core/management/base.py",
line 390, in run_from_argv
self.execute(*args, **cmd_options)
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/core/management/base.py",
line 441, in execute
output = self.handle(*args, **options)
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
line 93, in handle
executor = MigrationExecutor(connection,
self.migration_progress_callback)
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/migrations/executor.py",
line 19, in __init__
self.loader = MigrationLoader(self.connection)
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
line 47, in __init__
self.build_graph()
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/migrations/loader.py",
line 180, in build_graph
self.applied_migrations = recorder.applied_migrations()
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/migrations/recorder.py",
line 60, in applied_migrations
return set(tuple(x) for x in self.migration_qs.values_list("app",
"name"))
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/models/query.py",
line 162, in __iter__
self._fetch_all()
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/models/query.py",
line 965, in _fetch_all
self._result_cache = list(self.iterator())
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/models/query.py",
line 1220, in iterator
for row in compiler.results_iter():
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
line 783, in results_iter
results = self.execute_sql(MULTI)
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
line 829, in execute_sql
cursor.execute(sql, params)
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/backends/utils.py",
line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/backends/utils.py",
line 64, in execute
return self.cursor.execute(sql, params)
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/utils.py",
line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File
"/root/.virtualenvs/archivedb/local/lib/python2.7/site-packages/django/db/backends/utils.py",
line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: permission denied for relation
django_migrations
(archivedb)root@supercrunch:~/archivedb#
I'm not at all sure what this means. Any help will be sincerely appreciated.
Gary R.
--
https://mail.python.org/mailman/listinfo/python-list