How to link MySQL database with Python under Ubuntu system

Source: Internet
Author: User
Tags root access
Under Root access

Apt-get Install Mysql-serverapt-get Install mysql-client

Create a database

Mysql-u root-p passward linked databases CREATE DATABASE Basenameuse basename

If the database exists to be changed, it can be used directly

Mysql-u root-p Passward basename


Create a table

CREATE TABLE latest_face (ID int (one) not NULL auto_increment, camera_id varchar (+) NOT null, picture Mediumblob NOT NULL  , datetime datetime NOT NULL, people_id int (one) not NULL, People_name varchar (+), accessed int (4) Not null,primary key (ID) ) charset = gb2312;

Link the database with Python.

When using Apt-get install Mysql-python, you will be prompted not to find the package Mysql-python. But the direct download and installation is very troublesome, so use pip install Mysql-python

When using PIP install Mysql-python, prompt environmenterror:mysql_config not found. At this point reinstall Libmysqlclient-dev,pt-get Install Libmysqlclient-dev, then pip install Mysql-python. The installation was successful.

Enter import mysqldb under Python to test whether you can use the

The above is a small series to introduce you to the Ubuntu system Python link MySQL database method, I hope we have some help, if you have any questions please give me a message, small series will promptly reply to you. Thank you very much for your support for topic.alibabacloud.com!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.