Code

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#5776 closed (fixed)

Conflict between tutorial and 'Get your database running' section of the 'How to install Django' page

Reported by: Jeff@… Owned by: nobody
Component: Documentation Version: master
Severity: Keywords: mysql
Cc: Triage Stage: Someday/Maybe
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This snippet from the 'Get your database running' section of the 'How to install Django' page specifies a limited set of permissions needed for the database user:

If you plan to use Django’s manage.py syncdb command to automatically create database tables for your models, you’ll need to ensure that Django has permission to create tables in the database you’re using; if you plan to manually create the tables, you can simply grant Django SELECT, INSERT, UPDATE and DELETE permissions. Django does not issue ALTER TABLE statements, and so will not require permission to do so. If you will be using Django’s testing framework with data fixtures, Django will need permission to create a temporary test database.


However running through the tutorial caused these errors that were corrected by adding ALTER and INDEX permissions:

prompt:~/development/tutsite XXX$ python2.4 manage.py syncdb

Creating table auth_message
Creating table auth_group
Creating table auth_user
Traceback (most recent call last):

File "manage.py", line 11, in ?

execute_manager(settings)

File "/opt/local/lib/python2.4/site-packages/django/core/management.py", line 1672, in execute_manager

execute_from_command_line(action_mapping, argv)

File "/opt/local/lib/python2.4/site-packages/django/core/management.py", line 1571, in execute_from_command_line

action_mapping[action](int(options.verbosity), options.interactive)

File "/opt/local/lib/python2.4/site-packages/django/core/management.py", line 534, in syncdb

cursor.execute(statement)

File "/opt/local/lib/python2.4/site-packages/django/db/backends/util.py", line 12, in execute

return self.cursor.execute(sql, params)

File "/opt/local/lib/python2.4/site-packages/MySQLdb/cursors.py", line 163, in execute

self.errorhandler(self, exc, value)

File "/opt/local/lib/python2.4/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler

raise errorclass, errorvalue

_mysql_exceptions.OperationalError: (1142, "ALTER command denied to user 'django'@'localhost' for table 'auth_message'")

------------------------

prompt:~/development/tutsite XXX$ python2.4 manage.py syncdb
Creating table auth_permission
Creating table django_content_type
Creating table django_session
Creating table django_site
Installing index for auth.Permission model
Failed to install index for auth.Permission model: (1142, "INDEX command denied to user 'django'@'localhost' for table 'auth_permission'")Loading 'initial_data' fixtures...
No fixtures found.

Attachments (4)

5776.diff (873 bytes) - added by arien <regexbot@…> 6 years ago.
5776-alternative.diff (904 bytes) - added by arien <regexbot@…> 6 years ago.
5776-another-possibility.txt (361 bytes) - added by Jeff@… 6 years ago.
Another possible edit …
5776.mysql_index.diff (1.0 KB) - added by Lou Quillio <public@…> 6 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

The documentation says there "if you plan to manually create the tables". Using syncdb isn't manually creating them.

I guess the following sentence which mentions no need for ALTER TABLE isn't clearly linked to the previous sentence. If you think you car write it clearer, give it a go and attach the patch!

Changed 6 years ago by arien <regexbot@…>

Changed 6 years ago by arien <regexbot@…>

comment:2 Changed 6 years ago by arien <regexbot@…>

  • Has patch set

Either of these two patches will do, I think.

(The first patch changes the wording, while the second only changes punctuation.)

comment:3 Changed 6 years ago by Jeff@…

I'm just getting back to this, and it looks like I'm late.

I'm also new to Django and this ticket system so I don't know how to attach the a diff file for this.

I think a better solution might be to split it into two paraagraphs. One for automatically created table permission requirements, and the other for manually created database tables.

I still find the sentence about 'no ALTER permission' is needed by Django. It still looks like it is required by Django, but only if you're using syncdb to manage tables. Its not required if you manually manage the tables. Am I missing soemthing here ?

Changed 6 years ago by Jeff@…

Another possible edit ...

comment:4 Changed 6 years ago by ubernostrum

  • Resolution set to fixed
  • Status changed from new to closed

(In [6794]) Fixed #5776: Added an explanation of when and why Django might need ALTER TABLE privileges to docs/install.txt

comment:5 Changed 6 years ago by Lou Quillio <public@…>

  • Keywords mysql added
  • Triage Stage changed from Accepted to Someday/Maybe
  • Version changed from 0.96 to SVN

When using syncdb with models.ForeignKey() against MySQL 5.0, I found that the MySQL user also needs INDEX. Not sure how ambitious install.txt means to be with edge cases, but there's a patch attached just the same.

LQ

Changed 6 years ago by Lou Quillio <public@…>

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.