Tag Archives: NameError: name ”_ MySQL ‘is not defined

[Solved] Django configures MySQL Error: NameError: name ”_MySQL ‘is not defined

first install mysql, and then modify Django’s setting. Py
The original:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR/'db.sqlite3',
    }
}

Amend to read:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',  # Database engine
        'NAME': 'database name',
        'USER': 'User name',
        'PASSWORD': 'password',
        'HOST': '127.0.0.1', # ip of the host where mysql service is located
        'PORT': '3306', # mysql service port
    }
}

add environment variables (address NameError: name ‘_mysql’ is not defined)
Add to the environment variable:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

Then it’s done