I got curious how to connect to a MySQL server from C. This code is a rip-off from another blog but made minor modifications to get rid of compile warnings. My test system is Snow Leopard 10.6.3.


Compile by:

gcc -o test $(mysql_config --cflags) test.c $(mysql_config --libs)

Code