Westy92.com If you're bored enough, go ahead and read this. :)


Reading From a MySQL Database Using C++

I Googled it. I could not find an easy example of how to set up an environment to do this, so I decided to research a bunch and write my own tutorial!

First things first. You need:

  • Ubuntu (or other linux distribution)
  • A functioning MySQL database to read from
  • Patience!

The first thing you need to do is to install the MySQL++ library on linux.  Open up Terminal and type "sudo apt-get install libmysql++-dev" and press enter.

It should ask for your password, so type that in and watch it install MySQL++.

Now that that is over, create a new folder and navigate to it in Terminal.  Create two blank files, naming one "main.cpp" and "makefile" for the other.

Inside of "main.cpp", paste the following:

Inside of "makefile", paste the following:

Now, you have the basic template saved. You must fill in your MySQL database information for the variables "db", "server", "user", and "pass" in order for this program to work.

Once you have the database info filled in, where it says "select * from database", you may change that to something more appropriate, such as "select first_name, last_name, user_id, email from users".

Now you may simply save it, run "make" and then run the program.



Comments (0) Trackbacks (0)

No comments yet.

Leave a comment


Login with Facebook:

No trackbacks yet.

online games juegos gratis games online free games free online games
online game jogos online jeux gratuits giochi gratis oyunlar