NomisCZ / hlstatsx-community-edition

HLstatsX Community Edition - PHP 7 and GeoIP2 supported
GNU General Public License v2.0
83 stars 48 forks source link

Could not connect to database server. #59

Closed WojenHere closed 4 years ago

WojenHere commented 4 years ago

Describe the bug After entering ip.of.my.vps/stats/hlstats.php, site shows this error:

ERROR

Database ErrorServer

Address: localhost Server Username: hlxuser

Error Diagnostic: Could not connect to database server. Check that the values of DB_ADDR, DB_USER and DB_PASS in config.php are set correctly.

Server Error: ()

Last SQL Query: (empty)

Confirmed username and password many times and on both config files, tried using localhost, 127.0.0.1, ip.of.my.vps with and without adding port, same result.

Environment

Additional context HL stats newest log:

2020-05-12 23:15:00: - MYSQL: Connecting to MySQL database 'hlstatsx' on 'localhost' as user 'hlxuser' ... connected ok 2020-05-12 23:15:00: - CONFIG: Reading database config... 2020-05-12 23:15:00: - CONFIG: I have found the following server configs in database: 2020-05-12 23:15:00: - HLSTATSX: HLstatsX:CE 1.7.0 starting... 2020-05-12 23:15:00: - UDP: Opening UDP listen socket on port 27500 ... ok 2020-05-12 23:15:00: - HLSTATSX: Tracking Trend of the stats are enabled 2020-05-12 23:15:00: - HLSTATSX: Maximum Skill Change on all servers are 25 points 2020-05-12 23:15:00: - HLSTATSX: Minimum Skill Change on all servers are 2 points 2020-05-12 23:15:00: - HLSTATSX: Minimum Players Kills on all servers are 50 kills 2020-05-12 23:15:00: - HLSTATSX: Players chat logging is enabled 2020-05-12 23:15:00: - HLSTATSX: Broadcasting public chat is disabled 2020-05-12 23:15:00: - HLSTATSX: Event queue size is set to 10 2020-05-12 23:15:00: - HLSTATSX: HLstatsX:CE is now running (Normal mode, debug level 1) 2020-05-12 23:16:59: - HLSTATSX: No data since 120 seconds 2020-05-12 23:18:59: - HLSTATSX: No data since 120 seconds 2020-05-12 23:20:03: - HLSTATSX: Insert new server trend timestamp 2020-05-12 23:20:59: - HLSTATSX: No data since 120 seconds 2020-05-12 23:22:59: - HLSTATSX: No data since 120 seconds 2020-05-12 23:24:59: - HLSTATSX: No data since 120 seconds 2020-05-12 23:25:03: - HLSTATSX: Insert new server trend timestamp 2020-05-12 23:26:59: - HLSTATSX: No data since 120 seconds 2020-05-12 23:28:59: - HLSTATSX: No data since 120 seconds 2020-05-12 23:30:03: - HLSTATSX: Insert new server trend timestamp 2020-05-12 23:30:59: - HLSTATSX: No data since 120 seconds 2020-05-12 23:33:00: - HLSTATSX: No data since 120 seconds 2020-05-12 23:35:00: - HLSTATSX: No data since 120 seconds 2020-05-12 23:35:04: - HLSTATSX: Insert new server trend timestamp 2020-05-12 23:37:00: - HLSTATSX: No data since 120 seconds 2020-05-12 23:39:00: - HLSTATSX: No data since 120 seconds 2020-05-12 23:40:04: - HLSTATSX: Insert new server trend timestamp 2020-05-12 23:41:00: - HLSTATSX: No data since 120 seconds

NomisCZ commented 4 years ago

Hello, "Could not connect to database server." looks like you have a problem with the database server / connection between web and server. Maybe you're trying to connect from the ouside, but default MySQL bind only 127.0.0.1/localhost, check MySQL server config / firewall (port 3306).

You can use 127.0.0.1/localhost only if your MySQL and web are on the same server.

HLStatsX Daemon connects to the database without any problems ("2020-05-12 23:15:00: - MYSQL: Connecting to MySQL database 'hlstatsx' on 'localhost' as user 'hlxuser' ... connected ok").

There may also be a problem with MySQL 8 version, functionality has not been tested and it's recommended to use MySQL 5.7/MariaDB equivalent.

MySQL remote access: https://www.digitalocean.com/community/tutorials/how-to-allow-remote-access-to-mysql