Django 默认使用的数据库是 Python 自带的 SQLite3,SQLite3 数据库并不适用于大型的项目。除此之外,Django 还支持以下几种数据库:
PostgerSQL(http://www.postgresql.org/)
MySQL(http:/http://www.mysql.com/)
Oracle(http://www.oracle.com)
安装 MySQL
MySQL 下载地址:http://http://dev.mysql.com/downloads/mysq/。
根据提示进行安装。
当 MySQL 安装完成后,在 Windows 命令提示符下进入 MySQL。
> mysql -u root -p
Enter password:*****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Sever version: 5.5.20-log MySQL Community Server (GPL)
Copyright (c) 2000,2011, Oracle and/or its affiliates.All rights reserved.
Oracle is a registered trandemark 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>
复制代码
MySQL 基本操作
查看当前库与表
mysql> show databases; #查看当前数据库下面的所有库
+--------------------+
| Datebase |
+--------------------+
| information_schema |
| mysql |
|performance_schema |
| test |
+-------------------+
4 rows in set (0.00 sec)
mysql> use test; #切换到test库
Database changed
mysql> show tables; # 查看当前test库下面的表
Empty set (0.00 sec)
复制代码
查看 MySQL 端口号
mysql> show global variables like 'port';
+------------------------+
| Variable_name | Value |
+------------------------+
|port | 3306 |
+------------------------+
1 row in set (0.00 sec)
复制代码
创建数据库。
mysql> CREATE DATABASE guest CHARACTER SET utf8;
Query OK,1 row affected (0.00 sec)
复制代码
创建 guest 库,用于我们开发的发布会签到项目。
搜索微信公众号:TestingStudio 霍格沃兹的干货都很硬核
评论