TA的每日心情 | 擦汗 昨天 09:05 |
---|
签到天数: 525 天 连续签到: 2 天 [LV.9]测试副司令
|
替换默认数据库配置
- vi sites/settings.py
- '''
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
- }
- }
- '''
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.mysql',
- 'NAME':'django',
- 'USER':'root',
- 'HOST':'localhost',
- 'PASSWORD':'',
- 'PORT':'3306',
- }
- }
复制代码 设置数据库编码
- vi /etc/my.cnf
- [mysqld]
- datadir=/var/lib/mysql
- socket=/var/lib/mysql/mysql.sock
- user=mysql
- # Disabling symbolic-links is recommended to prevent assorted security risks
- symbolic-links=0
- character_set_server=utf8
- [mysqld_safe]
- log-error=/var/log/mysqld.log
- pid-file=/var/run/mysqld/mysqld.pid
- [client]
- default-character_set=utf8
复制代码 创建数据库
- mysql -uroot
- create database django character set utf8
- exit
- sudo service mysqld restart
复制代码
|
|