Problems encountered and method Solutions
1. External import database files
Enter mysql, create a database sh_robot
source /home/exbot/sh_robot.sql
View database encoding format
show variables like “%char%”;
2. The database insert
Enter the relevant database: use the database name;
The presence of a query table exists: show tables;
It does not exist create create table table name;
insert into table (field 1, field name 2, ...) values (value 1, value 2, ...)
insert into childre(childno,fname) values(123,‘wanghao’);
3.c code compiler command language to operate the database
gcc connect.c -o connect.c -I /usr/include/mysql -L /usr/lib/mysql -lmysqlclient
4. taskID and extracted from the database command string taskName
select* from task where taskState=1 order by taskLastEditTime desc;
5.C language will be garbled characters reading database, the database code is characters uft-8, linux terminal is utf-8
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, "gbk");
Such operations can only meet the characters read from the database reinserted back no problem, but then the terminal does not show or
6. The need to set before the query property of the query, set the character set to utf8; mysql_query (& mysql, "set names utf8");
Linux terminal database and so may exhibit both a Chinese
7. Determine the database, linux terminal Chinese character coding characters must be uniform format