django中mysql配置及使用

# Django settings for mysite2 project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'test',                      # Or path to database file if using sqlite3.
        'USER': 'root',                      # Not used with sqlite3.
        'PASSWORD': 'root',                  # Not used with sqlite3.
        'HOST': 'localhost',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '3306',                      # Set to empty string for default. Not used with sqlite3.
    }
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
"settings.py" 151L, 5241C written                                                                        
root@ubuntu118:/home/python/work/mysite2/mysite2# python ../manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): y
Please enter either "yes" or "no": yes
Username (leave blank to use 'root'): 
E-mail address: 
Error: That e-mail address is invalid.
E-mail address: 126170^H
Error: That e-mail address is invalid.
E-mail address: 1261720989@qq.com
Password: 
Password (again): 
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
root@ubuntu118:/home/python/work/mysite2/mysite2# ll
total 32
drwxr-xr-x 2 root root 4096 Oct 11 16:46 ./
drwxr-xr-x 3 root root 4096 Oct 11 15:38 ../
-rw-r--r-- 1 root root    0 Oct 11 15:38 __init__.py
-rw-r--r-- 1 root root  132 Oct 11 16:27 __init__.pyc
-rw-r--r-- 1 root root 5241 Oct 11 16:46 settings.py
-rw-r--r-- 1 root root 2865 Oct 11 16:46 settings.pyc
-rw-r--r-- 1 root root  559 Oct 11 15:38 urls.py
-rw-r--r-- 1 root root 1136 Oct 11 15:38 wsgi.py
root@ubuntu118:/home/python/work/mysite2/mysite2# cd ..
root@ubuntu118:/home/python/work/mysite2# ll
total 16
drwxr-xr-x 3 root   root   4096 Oct 11 15:38 ./
drwxrwxr-x 5 python python 4096 Oct 11 15:38 ../
-rwxr-xr-x 1 root   root    250 Oct 11 15:38 manage.py*
drwxr-xr-x 2 root   root   4096 Oct 11 16:46 mysite2/
root@ubuntu118:/home/python/work/mysite2# cd mysite2
root@ubuntu118:/home/python/work/mysite2/mysite2# ll
total 32
drwxr-xr-x 2 root root 4096 Oct 11 16:46 ./
drwxr-xr-x 3 root root 4096 Oct 11 15:38 ../
-rw-r--r-- 1 root root    0 Oct 11 15:38 __init__.py
-rw-r--r-- 1 root root  132 Oct 11 16:27 __init__.pyc
-rw-r--r-- 1 root root 5241 Oct 11 16:46 settings.py
-rw-r--r-- 1 root root 2865 Oct 11 16:46 settings.pyc
-rw-r--r-- 1 root root  559 Oct 11 15:38 urls.py
-rw-r--r-- 1 root root 1136 Oct 11 15:38 wsgi.py
root@ubuntu118:/home/python/work/mysite2/mysite2#
root@ubuntu118:/home/python/work/mysite2/mysite2# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 52
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hive               |
| mydatabase         |
| mysql              |
| performance_schema |
| test               |
+--------------------+
6 rows in set (0.00 sec)
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_test             |
+----------------------------+
| auth_group                 |
| auth_group_permissions     |
| auth_permission            |
| auth_user                  |
| auth_user_groups           |
| auth_user_user_permissions |
| django_content_type        |
| django_session             |
| django_site                |
| test                       |
+----------------------------+
10 rows in set (0.00 sec)

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏Android 开发学习

Android studio 2.2 JNI ffmpeg 简单的播放器(这里只有视频解码)include "libavcodec/avcodec.h"include "libavformat/avf

58130
来自专栏HansBug's Lab

1601: [Usaco2008 Oct]灌水

1601: [Usaco2008 Oct]灌水 Time Limit: 5 Sec  Memory Limit: 162 MB Submit: 1342  S...

30970
来自专栏Kubernetes

kube-controller-manager最佳配置

kubernetes version: 1.6.2 Kube-controller-manager Configuration kube-controller-...

53590
来自专栏竹清助手

安装MariaDB 无法登录解惑

Debian 9 installed mariadb-server , the phpmyadmin can't login and terminal too,...

18230
来自专栏大数据学习笔记

Hadoop基础教程-第11章 Hive:SQL on Hadoop(11.7 HQL:数据查询)(草稿)

第11章 Hive:SQL on Hadoop 11.7 HQL:数据查询 本节操作使用默认default数据库。 hive> use default; OK ...

226100
来自专栏数据库新发现

Emulex光纤卡lpfc配置文件的修改

# cd /kernel/drv # vi sd.conf "sd.conf" 65 lines, 1611 characters # # Copyright...

27820
来自专栏JMCui

MongoDB系列五(地理空间索引与查询).

Volvo Today, Volvo announced i...

31920
来自专栏架构技术

DevOps自动化工具集合

版本控制&协作开发:GitHub、GitLab、BitBucket、SubVersion、Coding、Bazaar

12820
来自专栏技术小黑屋

Package Stopped State Since Android 3.1

Since Android 3.1, Android has introduced a LaunchControl mechanism. It’s call S...

11510
来自专栏别先生

(Access denied for user 'root'@'slaver1' (using password: YES))

17920

扫码关注云+社区

领取腾讯云代金券