0

I'm new to Django and MySQL, and am trying to continue a project written by a previous developer.

I've just finished a fresh install of MySQL (didn't set any password). When I run python manage.py syncdb, I get the error:

python manage.py syncdb
/home/home/.virtualenvs/sorrento/local/lib/python2.7/site-packages/debug_toolbar/settings.py:134: DeprecationWarning: INTERCEPT_REDIRECTS is deprecated. Please use the DISABLE_PANELS config in theDEBUG_TOOLBAR_CONFIG setting.
  "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)

OperationalError: (1045, "Access denied for user 'home'@'localhost' (using password: NO)")

This is the database config in settings.py:

########## DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '',
        'USER': '',
        'PASSWORD': '',
        'HOST': '127.0.0.1',
        'PORT': '',
    }
}
########## END DATABASE CONFIGURATION

Since NAME is empty, does this mean there isn't a database set up? Do I need to get a database dump from the previous developer? Or is there something else I'm missing?

bard
  • 2,762
  • 9
  • 35
  • 49

2 Answers2

2

It is telling that you don't have permissions to edit the DB. To be able to connect you will need the NAME of the database and a USER and PASSWORD to connect with.

argaen
  • 4,145
  • 24
  • 28
  • In other words, I need to get the NAME, USER and PASSWORD from the previous developer? There's no other way to get these? – bard Mar 12 '15 at 12:02
  • 1
    @bard Yes you will need those. Or create your own db. – Raja Simon Mar 12 '15 at 12:04
  • 1
    Yup, if there is an already working webapp, there must be a configuration file specifying them. If not, if you have root access, you can try to access mysql as root to check the existing users and databases. Check [this post](http://stackoverflow.com/questions/2101694/mysql-how-to-set-root-password-to-null) second answer. – argaen Mar 12 '15 at 12:05
2

You don't need to get a copy of the db from the previous developer unless you actually need any of the data from there.

You have a fresh install of MySQL, so you just need to create an (empty) database.

Firstly, edit your db settings so that the USER attribute is 'root' and the NAME attribute is a relevant name (perhaps the name of your project).

Then, from the shell, do mysql -u root and then CREATE DATABASE <dbname> where dbname is the NAME you used above.

Now you should be able to run syncdb.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895