How to tell Django about using MySql from a WAMP installation?

I had Django working with Sqlite for a while. Then I installed WAMP, and now I want to prepare for serial launch and would like to switch to MySql. Is there an easy way to talk about this MySql instance that works with WAMP?

+3
source share
4 answers

as Ignacio already indicated that you need to change your settings.py. If you are using the latest version of Django (it will be 1.2.x), then you will have this settings.py parameter:

DATABASES = {
    'default': {
        'ENGINE': '',
        'NAME': '',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}

Here you can determine which database you are using.

In your case, this section should look like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '',
        'USER': 'your-mysql-username',
        'PASSWORD': 'your-mysql-users-password',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}

MySQL, IP- (localhost = 127.0.0.1) (3306). MySQL . IP .

, .

+3

settings.py.

+1

By default, these are the settings that you should use with WAMP / MySQL, which I consider ...

DATABASE_ENGINE = 'django.db.backends.mysql'
DATABASE_NAME = ''
DATABASE_USER = 'root'
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''
0
source

first install the mysqldb module for python by typing the following command:

easy_install mysql-python

at the command line / python client, and then change the settings.py options:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'Database Name',
        'USER': 'Database Username',
        'PASSWORD': 'Database Password',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}
0
source

Source: https://habr.com/ru/post/1746713/


All Articles