SA-MP Forums Archive
Couldn't establish a MySQL connection - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Couldn't establish a MySQL connection (/showthread.php?tid=649711)



Couldn't establish a MySQL connection - ranme15 - 13.02.2018

Aye

I am getting this error while running my server:
Код:
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 код:
    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?


Re: Couldn't establish a MySQL connection - iKarim - 14.02.2018

Quote:
Originally Posted by ranme15
Посмотреть сообщение
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?


Re: Couldn't establish a MySQL connection - ranme15 - 14.02.2018

Quote:
Originally Posted by iKarim
Посмотреть сообщение
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.


Re: Couldn't establish a MySQL connection - Lvcnr - 14.02.2018

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.


Re: Couldn't establish a MySQL connection - ranme15 - 14.02.2018

Quote:
Originally Posted by Lvcnr
Посмотреть сообщение
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!