用gcc批量建mysql库表

2008-02-23 07:41:06来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

file 1

my.c

//--------------------------------------------------------

// MySQL Database Create 1/13/2001. Netkiller Chen

//--------------------------------------------------------

#include

#include

main()

{

char host[16]; //mysql host address.

char sid[15]; //root user name.

char pwd[15]; //root password.

/* char *table_file[]={

"gsxx",

"bcxx",

"fgxx",

"hmbxx",

"ltxx",

NULL

};*/

//char *mysql;

char mydatabase[256];

char mysqltable[256];

int i;

int max_table_num;

int db,status;

i=0;

max_table_num=4; //max_table_num

system("clear");

showme();printf("\n");

printf("MySQL host:");scanf("%s",host);

printf("Root user:");scanf("%s",sid);

printf("Password:");scanf("%s",pwd);

printf("Loading........\n\n");

while(table_file[i]){

sprintf(mydatabase,"echo \"create database %s\"|mysql -h%s -u%s -p%s",table_file[i],host,sid,pwd);

sprintf(mysqltable,"mysql -h%s -u%s -p%s %s<%s.sql",host,sid,pwd,table_file[i],table_file[i]);

db=system(mydatabase);

status=system(mysqltable);

// printf("%s\n%s",mydatabase,mysqltable);

printf(table_file[i]);

//printf("%d",status);

if(db==0 && status==0){

printf("\t\t\tInstall [ OK ]\n");

}else{

printf("\t\t\tInstall [ :( ]\n");

}

i ;

}

address();

}

//------------------- Function ------------------

showme()

{

printf("-------------------------------------------------------------------\n");

printf("\tI am Netkiller Chen.\n");

printf("\tI am a programmer and system&net manager.\n");

printf("\tI am glad to be friend with you!\n");

printf("-------------------------------------------------------------------\n");

}

address()

{

printf("\n----------------------------------\n");

printf("|\tnewtech@sina.com |\n");

printf("|\tOICQ:13721218 |\n");

printf("|\t 1/13/2001 |\n");

printf("----------------------------------\n");

}

file 2

table.h

char *table_file[]={

"alxx",

"bcxx",

"fycx",

"fyxwxx",

"fyzxxx",

"hwzx",

"lhzxxx",

"xxdexx",

"xxdsxx",

"xxfgxx",

"xxglxx",

"xxgsxx",

"xxhmbxx",

"xxhtxx",

"xxjbxx",

"xxltxx",

"xxzwxx",

"xxzx",

NULL

};

些程式能够方便建表。。。有什么不明白和我联系。

程式随算不上什么。。。。。但也解决了一些批量建表的问提。

这个程式能够做为gcc刚入门爱好的参考,因为这个程式象hello world相同间简单。而且很全包括了指针,数组,文档包含,NULL

用户方法两个文档置于。/root/mygcc/下,将预建库mysql语句文档,文档名命名为xxxx.sql同上然后

#gcc my.c -o my

#my

即可。。。不用我在说了吧?


标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇: 一个基于mysql的登陆验证程式

下一篇: 使一个新的MySQL安装更安全