栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

ubuntu系统下 python链接mysql数据库的方法

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ubuntu系统下 python链接mysql数据库的方法

进入root 权限下

apt-get install mysql-server
apt-get install mysql-client

创建数据库

mysql -u root -p passward 链接数据库
create database basename
use basename

如果数据库存在要进行改动可以直接使用

mysql -u root -p passward basename

创建表

create table latest_face( id int(11) not null auto_increment, camera_id varchar(240) not null, picture mediumblob not null, datetime datetime not null, people_id int(11) not null, people_name varchar(16),accessed int(4) not null,primary key(id) )charset = gb2312;

用python链接数据库。

当使用apt-get install mysql-python 的时候,会提示未发现软件包mysql-python。但是直接下载再安装又非常麻烦,所以使用了pip install mysql-python

在使用pip install mysql-python的时候,提示EnvironmentError: mysql_config not found。此时重装libmysqlclient-dev,pt-get install libmysqlclient-dev,然后pip install mysql-python.就安装成功了

在python下输入import MySQLdb测试是否可以使用

以上所述是小编给大家介绍的ubuntu系统下 python链接mysql数据库的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对考高分网网站的支持!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/33232.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号