<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>一个故事@MySQL DBA &#187; Linux Programming</title>
	<atom:link href="http://www.orczhou.com/index.php/tag/linux-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.orczhou.com</link>
	<description>一个故事@MySQL DBA</description>
	<lastBuildDate>Tue, 20 Dec 2011 15:51:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Linux下C语言连接MySQL</title>
		<link>http://www.orczhou.com/index.php/2010/01/linux-c-mysql-api/</link>
		<comments>http://www.orczhou.com/index.php/2010/01/linux-c-mysql-api/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 11:21:30 +0000</pubDate>
		<dc:creator>orczhou</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[技术细节]]></category>
		<category><![CDATA[Linux Programming]]></category>

		<guid isPermaLink="false">http://www.orczhou.com/?p=1323</guid>
		<description><![CDATA[<p>相对于Window下的设置，Linux要简单的很多。</p>
<p><font color="red">1. 示例程序</font></p>
<pre>
<div class="mycode">$ vi mysql-c-api.c
#include &#60;stdio.h&#62;
#include "mysql/mysql.h"
int main(){
        MYSQL mysql;
        mysq[......]</div></pre><p class='read-more'><a href='http://www.orczhou.com/index.php/2010/01/linux-c-mysql-api/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p>相对于Window下的设置，Linux要简单的很多。</p>
<p><font color="red">1. 示例程序</font></p>
<pre>
<div class="mycode">$ vi mysql-c-api.c
#include &lt;stdio.h&gt;
#include "mysql/mysql.h"
int main(){
        MYSQL mysql;
        mysql_init(&#038;mysql);
        mysql_options(&#038;mysql,MYSQL_OPT_COMPRESS,0);
        mysql_options(&#038;mysql,MYSQL_INIT_COMMAND,"SET autocommit=0");
        if (!mysql_real_connect(&#038;mysql,"10.2.3.4","user","passwd","database",0,NULL,0))
        {
                fprintf(stderr, "Failed to connect to database: Error: %sn",
                mysql_error(&#038;mysql));
        }
        return 0;
}
</div>
</pre>
<p><font color="red">2. 编译命令</font></p>
<p>在MySQL编译后的二进制文件中，有一个很有用的二进制文件“<a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-config.html">mysql_config</a>”（一般和mysql命令在同一个目录下），我们可以通过这个程序找到需要的头文件和连接库：</p>
<pre>
<div class="mycode">$ gcc -o a.out $(mysql_config --cflags) <strong>mysql-c-api.c</strong> $(mysql_config --libs)
$ ./a.out
</div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.orczhou.com/index.php/2010/01/linux-c-mysql-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

