偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

安裝MySQL數(shù)據(jù)庫中獲得 MySQL.h 建立C接口的操作流程

數(shù)據(jù)庫 MySQL
今天主要向大家描述的是安裝MySQL數(shù)據(jù)庫中獲得 MySQL.h 建立C接口的實(shí)際操作步驟,下面就是文章的主要內(nèi)容描述,望你會(huì)有所收獲。

此文章主要向大家描述的是安裝MySQL數(shù)據(jù)庫中獲得 MySQL.h 建立C接口的實(shí)際操作流程,首先我們是從安裝MySQL數(shù)據(jù)庫開始的,其中涉及相關(guān)的實(shí)際應(yīng)用代碼的描述,下面就是文章的具體內(nèi)容描述。

先安裝MySQL

代碼:

  1. sudo apt-get install MySQL-server MySQL-client 

再裝開發(fā)包

代碼:

  1. sudo apt-get install libMySQLclient15-dev 

安裝MySQL數(shù)據(jù)庫完以后,C代碼里添加頭文件

代碼:

  1. #include <mysql.h> 

編譯方法:

代碼:

  1. gcc $(mysql_config --cflags) xxx.c -o xxx $(mysql_config --libs) 

可以用以下代碼測試一下

代碼:

  1. /* Simple C program that connects to MySQL Database server*/  
  2. #include <mysql.h> 
  3. #include <stdio.h> 
  4. main() {  
  5. MYSQL *conn;  
  6. MYSQL_RES *res;  
  7. MYSQL_ROW row;  
  8. char *server = "localhost";  
  9. char *user = "root";  
  10. char *password = "";   

此處改成你的密碼

  1. char *database = "mysql";  
  2. conn = mysql_init(NULL);  
  3. /* Connect to database */  
  4. if (!mysql_real_connect(conn, server,  
  5. user, password, database, 0, NULL, 0)) {  
  6. fprintf(stderr, "%s\n", mysql_error(conn));  
  7. exit(1);  
  8. }  
  9. /* send SQL query */  
  10. if (mysql_query(conn, "show tables")) {  
  11. fprintf(stderr, "%s\n", mysql_error(conn));  
  12. exit(1);  
  13. }  
  14. res = mysql_use_result(conn);  
  15. /* output table name */  
  16. printf("MySQL Tables in mysql database:\n");  
  17. while ((row = mysql_fetch_row(res)) != NULL)  
  18. printf("%s \n", row[0]);  
  19. /* close connection */  
  20. mysql_free_result(res);  
  21. mysql_close(conn);  
  22. }  

 

會(huì)輸出現(xiàn)有數(shù)據(jù)庫和表內(nèi)容。以上的相關(guān)內(nèi)容就是對(duì)安裝MySQL數(shù)據(jù)庫獲得 MySQL.h 建立C接口的介紹,望你能有所收獲。

【編輯推薦】

  1. MySQL 群集的概念與ndb群集構(gòu)架圖
  2. C#開發(fā)MySQL中文亂碼的妙招
  3. MySQL 事件調(diào)度器示例演示
  4. 實(shí)現(xiàn)MySQL數(shù)據(jù)庫備份,很簡單!
  5. MySQL匹配模式的實(shí)現(xiàn)方案簡介

     
責(zé)任編輯:佚名 來源: cnblogs
相關(guān)推薦

2010-05-20 17:56:43

2010-05-28 18:44:45

2011-03-03 10:00:14

ProFTPD建立MySQL

2010-05-25 09:47:05

2010-05-26 11:21:00

MySQL數(shù)據(jù)庫操作

2010-06-12 09:53:19

2010-05-12 18:02:11

MySQL數(shù)據(jù)庫

2010-06-12 17:48:45

MySQL數(shù)據(jù)庫表

2019-10-21 08:08:34

MySQL數(shù)據(jù)庫主鍵

2010-05-28 13:48:07

MySQL數(shù)據(jù)庫密碼

2011-07-05 18:04:45

QT Mysql

2010-06-01 09:32:09

MySQL數(shù)據(jù)庫

2010-05-11 13:50:56

MySQL數(shù)據(jù)庫

2010-06-04 18:45:00

MySQL數(shù)據(jù)庫

2010-05-24 14:02:06

MySQL數(shù)據(jù)庫

2010-06-04 10:59:54

MySQL數(shù)據(jù)庫返回影

2010-06-01 13:58:24

遠(yuǎn)程連接MySQL

2024-04-03 00:06:03

2010-06-10 08:48:14

2009-02-03 13:06:17

日常維護(hù)規(guī)范MySQL
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)