专栏首页闵开慧django中mysql配置及使用

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 条评论
登录 后参与评论

相关文章

  • ubuntu中的django安装配置与操作

    1 安装django,在安装前确保python已经安装,ubuntu中默认有安装的。我们只需要安装django即可,解压django压缩文件,进入解压后的文件夹...

    闵开慧
  • windows中django的安装

    1 下载python,解压,配置环境变量,将python的路径复制出来D:\tools\python273,粘贴到环境变量path中即可。 2 下载django...

    闵开慧
  • centos6.5桌面版网络设置情况

    DEVICE=eth0 TYPE=Ethernet UUID=3769d1ce-fcb8-4cc9-b4f6-fb24204d10ef ON...

    闵开慧
  • Linux音频驱动-ALSA概述

    ALSA(Advanced Linux Sound Architecture)是linux上主流的音频结构,在没有出现ALSA架构之前,一直使用的是OSS(Op...

    DragonKingZhu
  • 二叉树:我的左下角的值是多少?

    本地要找出树的最后一行找到最左边的值。此时大家应该想起用层序遍历是非常简单的了,反而用递归的话会比较难一点。

    代码随想录
  • 大点干!早点散----------深入剖析GFS分布式文件系统

    Gluster File System,开源的分布式文件系统,是Scale存储的核心,能够处理千数量级的客户端.在传统的解决 方案中Glusterfs能够灵活的...

    不吃小白菜
  • 如何使用CP / SCP / RSYNC在Linux中排除特定目录?

    对于任何系统管理员或一般Linux操作系统用户而言,在服务器之间执行文件复制操作都是一项常见任务。在将文件从一个系统复制到另一个系统时,由于某些特定原因,我们可...

    用户6543014
  • LeetCode 783 & 530 Distance Between BST Nodes

    Given a Binary Search Tree (BST) with the root node root, return the minimum dif...

    大学里的混子
  • 226 Invert Binary Tree

    /** * Definition for a binary tree node. * function TreeNode(val) { * thi...

    用户1624346
  • 【剑指Offer】二叉树的镜像

    输入:root = [4,2,7,1,3,6,9] 输出:[4,7,2,9,6,3,1]

    小新哟

扫码关注云+社区

领取腾讯云代金券