简体   繁体   中英

How do I successfully install mysql and mysql-python connector?

I need to install Django, Mysql and Mysql python connector Mac os x Yosemite. I successfully installed Django. And I think I installed mysql too from seeing the mysql icon in system preference. And this Mysql-python connector............I did every possible way and could not get it working.

How do I install it? I downloaded the dmg file from the website and installed it. and I typed "mysqld" in the prompt.. it produces a lot of lines with some error message saying its aborting. And I have python 2.7 and 3.4 in my system. How do I go about this as well?

mysqld doens't work , does that mean mysql did not install correctly? or does it have something to do with mysql-python connector??

First of all make sure that you have the following installed in your virtual-environment :

MySQL-python==1.2.5
PyMySQL==0.6.6

Once the above is confirmed, you need to make the following changes to your settings.py file:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'db_name',
        'USER': 'root',
        'PASSWORD': '', 
        'HOST': '127.0.0.1',
        'PORT': '', 
    },
}

Install mysql by typing brew install mysql

In your bash_profile file, add the following line:

export PATH=/usr/local/mysql/bin:$PATH

Once the installation for mysql is complete, in the terminal type:

sudo /usr/local/mysql/support-files/mysql.server start

mysql service will start running. In another terminal, type mysql. You will mysql console. Create database "db_name" by typing CREATE database db_name

Once the database is created, inside your django project directory type python manage.py syncdb . And you are done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM