Can't connect to mysql database..
#1

I've started experiencing a weird problem... I can't connect to my database..

Here's the defines, etc.. Plus connection code, I use the newest version availiable R39-2.

I'm also using cache.. So bassicly here's the connection code:

pawn Code:
#define SQL_HOST "localhost"
#define SQL_USER "root"
#define SQL_DB "sql_learning"
#define SQL_PASS ""


public OnGameModeInit()
{
    connection = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
    mysql_log(LOG_ALL);
    /*if(connection > 0)
    {
        mysql_log(LOG_ALL);
        printf("[MYSQL]: Connection to `%s` successfull!", SQL_DB);
    }
    else
    {
        printf("[MYSQL]: [ERROR]: Connection to `%s` failed!", SQL_DB);
    }
*/

    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}
Plus here's the mysql_log(LOG_ALL) file:


PHP Code:
[01:07:32] [ERRORCMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on 'localhost' (10061)
[01:07:32] [DEBUGCMySQLConnection::Connect establishing connection to database...
[
01:07:32] [DEBUGCMySQLConnection::Connect establishing connection to database...
[
01:07:32] [DEBUGCMySQLConnection::Connect establishing connection to database...
[
01:07:33] [ERRORCMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on 'localhost' (10061)
[01:07:33] [ERRORCMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on 'localhost' (10061)
[01:07:33] [ERRORCMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on 'localhost' (10061) 
Reply
#2

So. Do you have a mysql server?
Reply
#3

If you are using XAMPP, check that you have the database "sql_learning" up and running.
Reply
#4

Quote:
Originally Posted by redist
View Post
If you are using XAMPP, check that you have the database "sql_learning" up and running.
It is up and running, and the mysql option in XAMP is also ticked on.


Quote:
Originally Posted by yanir3
View Post
So. Do you have a mysql server?
Nope, I'm just learning how to work with it on SA-MP.. Do you really think I'd create a MySQL server and not
have a Password for my database..
Reply
#5

Quote:
Originally Posted by Ox1gEN
View Post
It is up and running, and the mysql option in XAMP is also ticked on.
Weird... can u post pics of both your localhost/admin and your code?

EDIT: Use
pawn Code:
if(mysql_ping() == 1) // worked
{

}
else // didnt work
{

}
Reply
#6

Quote:
Originally Posted by redist
View Post
Weird... can u post pics of both your localhost/admin and your code?

EDIT:
Code:
use if(mysql_ping() == 1) // worked
{

}
else // didnt work
{

}
No, sorry.

And there's no mysql_ping in version R39-2.. I hate that..
Reply
#7

Quote:
Originally Posted by Ox1gEN
View Post
No, sorry.

And there's no mysql_ping in version R39-2.. I hate that..
No code, and no screen shots. We can't help hire a Psychic, we don't posses those powers here.

Have you tried basic MySQL diagnosics however, such as Rebooting WAMP/XAMPP what ever you have.
Did you set a password on MySQL?

Also, I find you get a lot less issues with MySQL if you create a user other than root, with a password. It just seems to go more smoothly, or I imagine it .
Reply
#8

I would strongly suggest to update to the latest release.

Threaded queries are not hard to learn and they are waaay more better for your server.
Reply
#9

Quote:
Originally Posted by IceCube!
View Post
No code, and no screen shots. We can't help hire a Psychic, we don't posses those powers here.

Have you tried basic MySQL diagnosics however, such as Rebooting WAMP/XAMPP what ever you have.
Did you set a password on MySQL?

Also, I find you get a lot less issues with MySQL if you create a user other than root, with a password. It just seems to go more smoothly, or I imagine it .
Well, I can't really post pictures but I just came across a thread that bassicly uses mysql_eerno
I don't really know what it is, but the way he wrote it I assume it's like mysql_ping, correct?

Quote:
Originally Posted by redist
View Post
I would strongly suggest to update to the latest release.

Threaded queries are not hard to learn and they are waaay more better for your server.
I am using the latest version, I mentioned that in the thread itself..
Reply
#10

Then try to use mysql_errno.

pawn Code:
if(mysql_errno() == 0) // If it is EQUAL to 0, then there is no error
{
//...
}
It should work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)