A. mysql install
1. download mysql
https://dev.mysql.com/downloads/mysql/
* site may ask to join, but we don't need to join for download file
* install -> in case of Mac, show default password on popup window.
2. set path
$nano ~/.bash_profile
add this sentence
#mysql
export PATH=/usr/local/mysql/bin:$PATH
3. start mysql & set password
$ sudo /usr/local/mysql/support-files/mysql.server start
create a username with a password
$ mysqladmin -u root password yourpassword
or
change the password
$ mysqladmin -u root -p'oldpassword' password newpassword
4. create mysql database
login
$ mysql -u root -p Enter password:
create database
CREATE DATABASE taskbuster_db;
B. django setting
1. install pymysql
$pip install pymysql
2. django settings.py
import pymysql
pymysql.install_as_MySQLdb()
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql',
'NAME': 'django_locker', # DB name
'USER': '', # database user : root
'PASSWORD': '', # database pass
'HOST': '', # localhost
'PORT': '', # database port('' or 3306) } }
3. migration
$python manage.py makemigrations $python manage.py migrate
No comments:
Post a Comment