Can't connect to mysql database.. -
Ox1gEN - 27.08.2014
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] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on 'localhost' (10061)
[01:07:32] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[01:07:32] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[01:07:32] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[01:07:33] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on 'localhost' (10061)
[01:07:33] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on 'localhost' (10061)
[01:07:33] [ERROR] CMySQLConnection::Connect - (error #2003) Can't connect to MySQL server on 'localhost' (10061)
Re: Can't connect to mysql database.. -
yanir3 - 27.08.2014
So. Do you have a mysql server?
Re: Can't connect to mysql database.. -
redist - 27.08.2014
If you are using XAMPP, check that you have the database "sql_learning" up and running.
Re: Can't connect to mysql database.. -
Ox1gEN - 27.08.2014
Quote:
Originally Posted by redist
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
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..
Re: Can't connect to mysql database.. -
redist - 27.08.2014
Quote:
Originally Posted by Ox1gEN
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
{
}
Re: Can't connect to mysql database.. -
Ox1gEN - 27.08.2014
Quote:
Originally Posted by redist
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..
Re: Can't connect to mysql database.. -
IceCube! - 27.08.2014
Quote:
Originally Posted by Ox1gEN
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
.
Re: Can't connect to mysql database.. -
redist - 27.08.2014
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.
Re: Can't connect to mysql database.. -
Ox1gEN - 27.08.2014
Quote:
Originally Posted by IceCube!
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
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..
Re: Can't connect to mysql database.. -
redist - 27.08.2014
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.