日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

ubuntu mysql开发_ubuntu linux mysql 开发模式与连接编译

發布時間:2025/3/11 数据库 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ubuntu mysql开发_ubuntu linux mysql 开发模式与连接编译 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

【源碼 測試】

#include

#include

#include

int main(void)

{

MYSQL_RES *result;

MYSQL_ROW row;

MYSQL *connection, mysql;

int state;

mysql_init(&mysql);

connection = mysql_real_connect(&mysql,"localhost","root","951241","mysql",0,0,0);

if (connection == NULL)

{

printf(mysql_error(&mysql));

return 1;

}

state = mysql_query(connection, "SELECT Host, User, Password FROM user");

if (state !=0)

{

printf(mysql_error(connection));

return 1;

}

result = mysql_store_result(connection);

printf("Rows:%d\n",mysql_num_rows(result));

while ( ( row=mysql_fetch_row(result)) != NULL )

{

printf("%s, %s, %s\n", (row[0] ? row[0] : "NULL"), (row[1] ? row[1] : "NULL" ), (row[2] ? row[2] : "NULL"));

}

mysql_free_result(result);

mysql_close(connection);

return 0;

};

【mysql】

要裝有Mysql 數據庫 apt-get install mysqlclient mysqlserver libmysqlclient-dev

【編譯】

sudo gcc $(mysql_config --cflags) main.c -o $(mysql_config --libs)

sudo g++ test.cpp -I/usr/include/mysql /usr/lib/mysql/libmysqlclient??? -----------------[這個沒上面那個好用,有可能目錄不對]

【部分錯誤分析1】

/home/qiang/client_soft/mysql/main.c||In function ‘main’:|

/home/qiang/client_soft/mysql/main.c|13|error: stray ‘\342’ in program|

/home/qiang/client_soft/mysql/main.c|13|error: stray ‘\200’ in program|

………………………………………………………………………………………………

finished: 10 errors, 5 warnings ===|

這個'342'是雙引號為漢字,由于是從網上down的,符號問題。。。。常常出現

【部分錯誤分析2】

包含文件不會。只要安裝好mysql和程序沒有問題,運行上邊編譯的命令(如果是IDE要手動加載),就不有問題。

【運行效果】數據庫 mysql.user 存在數據才有顯示 可以更改 上面的代碼

總結

以上是生活随笔為你收集整理的ubuntu mysql开发_ubuntu linux mysql 开发模式与连接编译的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。