"Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] Connection refused" after updating a PHP file

48 Views Asked by At

I have added a new column to a mySQL database table and added a form field for the new value to the PHP page which is used to display the values of the database fields for a selected record. The application (which is hosted on a shared server of a provider) itself is still working fine (access to mySQL tables is also fine), but when invoking the modified page with the new field, it gives the above mentioned error, in more detail:

Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] Connection refused in /kunden/XXX/webseiten/shoes/showrun.php:55 Stack trace: #0 /kunden/XXX/webseiten/shoes/showrun.php(55): PDO->__construct('mysql:host=mysq...', 'username', 'password') #1 {main} thrown in /kunden/XXX/webseiten/shoes/showrun.php on line 55

The strange thing is, that the code on line 55 which constructs a new PDO:

$pdo = new PDO('mysql:host=mysql5.my-domain.com;dbname=XXX', 'username', 'password');

is unchanged and exactly the same as in other, unmodified PHP pages, which still work without any errors.

Even more strange is, that when I roll back the changes in the PHP file and upload it again to the server (via WebFTP), so that it is identical to the one which was in place before (and worked without error) the same error message is displayed!

So the problem seems to be caused just by modifiying/uploading the file on the server. The rights on the file and its name and location are exactly like before, when everything was fine.

[Remark: username, password, my-domain and XXX are not the actual values and replaced for security reasons]

What can be the probable reason for this problem? Any help is much appreciated.

@Wilson Hauck: Like requested:

A)
Variable_name                   Value
character_set_connection        utf8mb4
collation_connection            utf8mb4_unicode_ci
connect_timeout                 12
disconnect_on_expired_password  ON
init_connect                    SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci
max_connect_errors              100
max_connections                 400
max_user_connections            50
performance_schema_session_connect_attrs_size   512

B)
Variable_name                   Value
Aborted_connects                77783
Connection_errors_accept        0
Connection_errors_internal      0
Connection_errors_max_connections 0
Connection_errors_peer_address  0
Connection_errors_select        0
Connection_errors_tcpwrap       0
Connections                     12942161
Locked_connects                 0
Max_used_connections            52
Max_used_connections_time       2022-06-22 23:23:19
Performance_schema_session_connect_attrs_lost 0
Ssl_client_connects             0
Ssl_connect_renegotiates        0
Ssl_finished_connects           0
Threads_connected               2

C)
Variable_name                   Value
Uptime                          4618314
0

There are 0 best solutions below