前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >django中mysql配置及使用

django中mysql配置及使用

作者头像
闵开慧
发布2018-03-30 13:13:41
1.3K0
发布2018-03-30 13:13:41
举报
文章被收录于专栏:闵开慧闵开慧
代码语言:javascript
复制
# 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)
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档