  | | | Unable to connect to db server on localhost | Unable to connect to db server on localhost 2007-06-21 - By Martin Persson
Back Hi,
I wanted to play around a bit with MySQL server 5.0, MySQL++ 2.2.3, and MingW 3.81 on a Windows XP SP2 system.
First I am actually a bit uncertain whether MySQL++ is built properly. I've followed the instructions in readme.mingw, but the make step doesnt put the binaries in the proper subdirectories (that is assuming for instance that the example executables should be in the examples subdirectory). No separate debug and release versions of the .a libraries are built. Running the final install.bat script will thus only create subdirectories, not actually move any files there. All the compiled files ended up in the c:\mysql++ directory, but I put copies of the .a files in c:\mysql++\lib\debug\ (assuming that the built libraries are debug versions), and put the mysql++.dll file where my compiled binary is.
Compilation issues aside it seems like my programs (both examples and code of my own) cant connect to the database server.
Mysql and the paths for it seem to be fine. I can connect to the db server manually from the location of the example binaries, and since this is a pure test system I've created three accounts with user names dba, usr, and rdr with passwords identical to the user names.
The exact procedure of my failed attempt to run the examples would be:
C:\mysql++>resetdb [localhost [dba [dba[]]]] Connecting to database server... Connection failed: Unknown MySQL server host '[localhost' (11001)
My own code which really just is a copy and paste job from the first example tries to connect to the db and get the name field of a particular table (the database was created manually before and only has one entry in that table):
#include <iostream> #include <iomanip> using namespace mysqlpp ; using namespace std ;
const char* DB = "recept"; const char* USER = "rdr"; const char* PASSWORD = "rdr"; const char* HOST = "localhost";
int main(int argc, char *argv[]) { // Connect to the sample database. mysqlpp::Connection con(false); cout << con.connect(DB, HOST, USER, PASSWORD) << endl; // Retrieve a subset of the sample stock table set up by resetdb mysqlpp::Query query = con.query(); cout << "test" << endl; query << "select namn from recept;"; mysqlpp::Result res = query.store(); // Display the result set cout << "We have:" << endl; if (res) { mysqlpp::Row row; mysqlpp::Row::size_type i; for (i = 0; row = res.at(i); ++i) { cout << '\t' << row.at(0) << endl; } } else { cerr << "Failed to get item list: " << query.error() << endl; return 1; } return 0; }
Running that gives the following results
0 test We have: Failed to get item list: MySQL server has gone away
Manually connecting to the database (mysql -hlocalhost -urdr -prdr recept and mysql -hlocalhost -udba -pdba) works from the location of either binary.
I suspect I have made some very basic mistake, is there a checklist of things to look for in this kind of situation?:) And I'm sorry if I wont react to your help right away, the midsummer holiday and my birthday is coming up here in Sweden.
Regards Martin
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ______ __ __ Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool. http://autos.yahoo.com/carfinder/
-- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: http://lists.mysql.com/plusplus?unsub=mysql@(protected)
|
|
 |