SA-MP Forums

Go Back   SA-MP Forums > SA-MP Server > Server Support

Reply
 
Thread Tools Display Modes
Old 13/02/2018, 09:31 PM   #1
ranme15
Big Clucker
 
ranme15's Avatar
 
Join Date: Aug 2010
Posts: 171
Reputation: 3
Default Couldn't establish a MySQL connection

Aye

I am getting this error while running my server:
Code:
Connection::Connection - establishing connection to MySQL database failed: #2003 'Can't connect to MySQL server on host (xx.xx.xx.xx) (111)
Pawn code:
PHP Code:
    new MySQLOptoption_id mysql_init_options();
    
mysql_set_option(option_idAUTO_RECONNECTtrue);
    
SQL mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_PASSWORDMYSQL_DATABASEoption_id);
    if (
SQL == MYSQL_INVALID_HANDLE || mysql_errno(SQL) != 0)
    {
        print(
"MySQL connection failed. Server is shutting down.");
        
SendRconCommand("exit");
        return 
1;
    } 
The parameters must be correct since I am able to log with these through phpMyAdmin. What could be the issue?
Might it be the fact im using a static Debian MySQL version?
__________________
INACTIVE
ranme15 is offline   Reply With Quote
Old 14/02/2018, 05:45 AM   #2
iKarim
Huge Clucker
 
iKarim's Avatar
 
Join Date: Oct 2015
Posts: 458
Reputation: 85
Default Re: Couldn't establish a MySQL connection

Quote:
Originally Posted by ranme15 View Post
Might it be the fact im using a static Debian MySQL version?
That doesn't affect your connection at all. However I'd like to know what's the host define you are using, is it localhost?
iKarim is offline   Reply With Quote
Old 14/02/2018, 06:15 AM   #3
ranme15
Big Clucker
 
ranme15's Avatar
 
Join Date: Aug 2010
Posts: 171
Reputation: 3
Default Re: Couldn't establish a MySQL connection

Quote:
Originally Posted by iKarim View Post
That doesn't affect your connection at all. However I'd like to know what's the host define you are using, is it localhost?
It is the IP address of my host.
__________________
INACTIVE
ranme15 is offline   Reply With Quote
Old 14/02/2018, 06:23 AM   #4
Lvcnr
Little Clucker
 
Lvcnr's Avatar
 
Join Date: Jul 2011
Location: LasVenturas.Net
Posts: 19
Reputation: 9
Default Re: Couldn't establish a MySQL connection

Are you hosting SA-MP server on the same server which has the mysql server? If so, try connecting to localhost. Otherwise, allow remote connections to your mysql server and then give it a shot.
__________________


Las Venturas Cops & Robbers (LVCNR)



Lvcnr is offline   Reply With Quote
Old 14/02/2018, 06:44 AM   #5
ranme15
Big Clucker
 
ranme15's Avatar
 
Join Date: Aug 2010
Posts: 171
Reputation: 3
Default Re: Couldn't establish a MySQL connection

Quote:
Originally Posted by Lvcnr View Post
Are you hosting SA-MP server on the same server which has the mysql server? If so, try connecting to localhost. Otherwise, allow remote connections to your mysql server and then give it a shot.
I gave 'localhost' a try after the first comment and it actually works. Thanks for your replies!
__________________
INACTIVE
ranme15 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Mysql] Couldn't connect to database. Glossy42O Scripting Help 8 04/01/2015 05:48 AM
[ HELP ] Couldn't Connecting to MYSQL . Why? SpikY_ Scripting Help 26 20/11/2014 04:16 PM
MySQL - Connection is dead - but connection is fine! Jochemd Help Archive 15 12/08/2011 10:14 AM
Connection doesn't establish ouyso Help Archive 4 27/12/2010 12:49 AM


All times are GMT. The time now is 08:26 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.