Author Topic: "db connection attempt failed" width the server  (Read 488 times)

psyche

  • Wayfarer
  • *
  • Posts: 8
    • View Profile
"db connection attempt failed" width the server
« on: February 19, 2005, 04:35:43 am »
After I finally compile the server successfully, I tried to run it, but another error appear :

db connection attempt failed

Initialize:
  Could not create database or connect to it.

Other applications (such as MySQLCC) had no problems to connect, the user and the databases needed by planeshift were created. So I decide to look in the source where the error exactly append ... It was this line (/src/server/database/mysql/dal.cpp, line 62) :

conn = mysql_real_connect(conn,host,user,pwd,
database,0,NULL,CLIENT_FOUND_ROWS);

It returned NULL instead of a MySQL*. I first thought it could be the host, user pwd etc that were false. So I \"printf\" them. They were normal. I finally replace the NULL, by the exact socket adress :

conn = mysql_real_connect(conn,host,user,pwd,
database,0,\"/var/lib/mysql/mysql.sock\",CLIENT_FOUND_ROWS);

Jam, try ... and it was working. Can anyone explain me ? Is something false in my linux configuration ? My method isn\'t clean ... Can anybody suggest me a better one ?
« Last Edit: February 19, 2005, 06:08:55 am by psyche »

Aerig

  • Hydlaa Resident
  • *
  • Posts: 76
    • View Profile
(No subject)
« Reply #1 on: February 19, 2005, 09:13:29 am »
This is the same problem that I had when trying to compile using Cygwin on Windows.

I cant tell you the answer, but here are some other things that I found out while I was trying to solve it ...

I cannot remember the exact details now, but the value, \"/var/lib/mysql/mysql.sock\", is (re)defineable, either in one of the MySQL source files or in the MySQL config file (on Windows my.ini).

When I tried to trace what was happening without changing the line

conn = mysql_real_connect(conn,host,user,pwd,
database,0,NULL,CLIENT_FOUND_ROWS);

I was getting errors along the lines of, could not create socket and/or the named socket (file) does not exist.

But, I did not compile the MySQL server from source, I compiled the client and got so many error trying to compile the server that I gave up.

Possibly, the default sockets defined in your server and client do not match?


A problem that I had elsewhere, that had similar symptoms was that, when I installed MySQL on a machine that had a LAN installed, the server defaulted to looking for connections from the LAN and not from the internet. This alsop resulted in failures to connect to the database.


I hope this might help you track down the problem and, if you solve it, that you will post the solution.