Question

So, I have a running project that uses a MySQL database with a MAMP local server but for compliance issues I need to change the database name. So I changed it in MAMP and I changed it in settings.py as seen bellow:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',  # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'prototipodb',                      # Or path to database file if using sqlite3.
        'USER': 'palapa',                      # Not used with sqlite3.
        'PASSWORD': 'palapa',                  # Not used with sqlite3.
        'HOST': '/Applications/MAMP/tmp/mysql/mysql.sock',  # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '3306',                      # Set to empty string for default. Not used with sqlite3.
    }
}

I thought that with these changes everything would keep running smoothly, but I got the following error on my server:

Unhandled exception in thread started by > Traceback (most recent call last): File "/Users/palapa2/projects/prototipo_tesis/venv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run self.validate(display_num_errors=True) File "/Users/palapa2/projects/prototipo_tesis/venv/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate num_errors = get_validation_errors(s, app) File "/Users/palapa2/projects/prototipo_tesis/venv/lib/python2.7/site-packages/django/core/management/validation.py", line 103, in get_validation_errors connection.validation.validate_field(e, opts, f) File "/Users/palapa2/projects/prototipo_tesis/venv/lib/python2.7/site-packages/django/db/backends/mysql/validation.py", line 14, in validate_field db_version = self.connection.get_server_version() File "/Users/palapa2/projects/prototipo_tesis/venv/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 415, in get_server_version self.cursor().close() File "/Users/palapa2/projects/prototipo_tesis/venv/lib/python2.7/site-packages/django/db/backends/init.py", line 306, in cursor cursor = self.make_debug_cursor(self._cursor()) File "/Users/palapa2/projects/prototipo_tesis/venv/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 387, in _cursor self.connection = Database.connect(**kwargs) File "build/bdist.macosx-10.9-intel/egg/MySQLdb/init.py", line 81, in Connect File "build/bdist.macosx-10.9-intel/egg/MySQLdb/connections.py", line 193, in init _mysql_exceptions.OperationalError: (1049, "Unknown database 'prototipodb'")

I would appreciate if you can help me with this problem. One of the things I've been thinking about doing is run syncbd command to rebuild the connection, but if there is a better solution to this I would gladly consider it.

Était-ce utile?

La solution

I just did this on my mac and it works fine. I copied the DB and changed the name in settings.py. Then I gave my user access to the new DB.`

Did you give user palapa access to the new DB?

Did you flush privileges?

Did you restart Django server?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top