flask mysql

 

sudo apt-get install mysql-server
mysql -u root -p

sudo apt-get install python-mysqldb

sudo apt-get install libmysqlclient-dev

sudo updatedb

locate mysql_config

sudo apt-get install python-dev

 pip install mysql-python

=============================

导出表结构及数据

 

mysqldump -u root -p 数据库名>数据库名.sql

==============================

mysql> use carloblog;

mysql> show tables;

+---------------------+
| Tables_in_carloblog |
+---------------------+
| roles               |
| t_nav               |
| users               |
+---------------------+
3 rows in set (0.00 sec)

mysql> show columns from t_nav;
+-------------+-------------+------+-----+---------+----------------+
| Field       | Type        | Null | Key | Default | Extra          |
+-------------+-------------+------+-----+---------+----------------+
| id          | int(11)     | NO   | PRI | NULL    | auto_increment |
| name        | varchar(64) | YES  | UNI | NULL    |                |
| level       | int(11)     | YES  |     | NULL    |                |
| is_public   | tinyint(1)  | YES  |     | NULL    |                |
| order       | int(11)     | YES  |     | NULL    |                |
| owner_id    | int(11)     | YES  |     | NULL    |                |
| create_time | datetime    | NO   |     | NULL    |                |
| update_time | datetime    | YES  |     | NULL    |                |
+-------------+-------------+------+-----+---------+----------------+

 

Mysqldb的安装

===============================

http://my.oschina.net/flynewton/blog/10880?catalog=43725

1.首先安装mysql

sudo apt-get install mysql-server

2.然后安装libmysqld-dev和libmysqlclient-dev,否则在安装Mysqldb的时候会报找不到mysql_config文件

sudo apt-get install libmysqld-dev
sudo apt-get install libmysqlclient-dev

3.安装完上述之后,到http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download下载最新的Mysqldb的tar包,解压

 

修改site.cfg中的mysql_config的配置地址,一般上述装完后的默认地址为/usr/bin/mysql_config
运行下列命令即可
sudo python setup.py build
sudo python setup.py install


============================
http://www.cnblogs.com/xiazh/archive/2012/07/31/2616474.html

安装python模块时出现:error: Setup script exited with error: command 'gcc' failed with exit status 1

通过安装如下库即可解决:

sudo apt-get install python-dev
posted @ 2015-03-19 02:18  carlo-z  阅读(370)  评论(0编辑  收藏  举报