well, given you havnt told us which breed/type of database you have/want to retrieve data from, we can only take a wild guess
a) download the appropriate Linux driver for the database - eg, for MySQL, start here
http://dev.mysql.com/downloads/connector/c/[
^] (there are RedHat, FreeBSD & SUSE drivers available as well)
b) Install driver/connector package
c) play with the samples - MySQL usually has some examples showing how to do the basics
d) write code for your own situation