ubuntu system python links to mysql database method
- 2020-05-19 05:08:26
- OfStack
Enter root permissions
apt-get install mysql-server
apt-get install mysql-client
Create a database
mysql -u root -p passward Linked database
create database basename
use basename
If the database exists and needs to be changed, it can be used directly
mysql -u root -p passward basename
Create a table
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;
Link to the database with python.
When using
apt-get install mysql-python
The package mysql-python is not found. But the direct download and then install is very troublesome, so used
pip install mysql-python
When using pip install mysql-python, prompt EnvironmentError: mysql_config not found. The reshipment
libmysqlclient-dev,pt-get install libmysqlclient-dev
And then
pip install mysql-python.
The installation was successful
Enter import MySQLdb under python to see if it works