evolution-cms / evolution

Welcome to the new evolution of MODX Evolution!
GNU General Public License v3.0
260 stars 96 forks source link

Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory #2108

Closed q2apro closed 1 year ago

q2apro commented 2 years ago

I copied Evolution CMS v3 from one server to another server.

The new server has a relational database (external database). Instead of localhost another IP 192.168.0.28 is used.

The \core\config\database\connections\default.php looks like this:

<?php
return [
    'driver' => env('DB_TYPE', 'mysql'), //$database_type
    'host' => env('DB_HOST', '192.168.0.28'), //$database_server
    'port' => env('DB_PORT', '3306'), //$database_port
    'database' => env('DB_DATABASE', 'mydatabase'), //$dbase
    'username' => env('DB_USERNAME', 'root'), //$database_user
    'password' => env('DB_PASSWORD', 'mypassword12345'), //$database_password
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => env('DB_CHARSET', 'utf8mb4'), // $database_connection_charset
    'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), //$database_collation
    'prefix' => env('DB_PREFIX', 'evo_'), //$table_prefix
    'method' => env('DB_METHOD', 'SET CHARACTER SET'), //$database_connection_method
    'strict' => env('DB_STRICT', false),
    'engine' => env('DB_ENGINE', 'innodb'),
    'options' => [
        PDO::ATTR_STRINGIFY_FETCHES => true,
    ]
];

The CMS still does not load. It throws the Error message:

[php7:error] [pid 72925] [client 127.0.0.1:47820] PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /core/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:40\nStack trace:\n#0 /core/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(40): PDO->construct()\n#1 /core/vendor/illuminate/database/Connectors/Connector.php(67): Doctrine\DBAL\Driver\PDOConnection->construct()\n#2 /core/vendor/illuminate/database/Connectors/Connector.php(46): Illuminate\Database\Connectors\Connector->createPdoConnection()\n#3 /core/vendor/illuminate/database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection()\n#4 /core/vendor/illuminate/database/Connectors/ConnectionFactory.php(184): Illuminate\Database\Connectors\MySqlConnector->connect()\n#5 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}()\n#6 /core/vendor/illuminate/ in /core/vendor/illuminate/database/Connection.php on line 712

How can I fix this? Do I need to reinstall the CMS? Or is there a config option I can add/change?

q2apro commented 2 years ago

They write here: https://stackoverflow.com/a/56897820/1066234 that after changing the config, PHP Artisan must be run:

php artisan config:cache

However, I do not have Artisan/Laravel installed on the server.

And is it really necessary to make Evo CMS load another config?

q2apro commented 1 year ago

Turns out that the database credentials were not correct.

If you have the same problem, open your correct FTP path. E.g. \core\config\database\connections\default.php and make sure all data is correct. Use the same data to login in phpmyadmin or alike to verify it is correct there too.