DB connection error, new install

Hi everyone, I’m having a DB connection error during the MODX Installer, “Connecting to database server” outputs:-

Could not connect to the database server. Check the connection properties and try again.

[2022-10-26 14:00:55] (ERROR in xPDO\xPDOConnection::connect @ /home/olly/public_html/modx/public/core/vendor/xpdo/xpdo/src/xPDO/xPDOConnection.php : 89) SQLSTATE[HY000] [2019] Unknown character set

[2022-10-26 14:00:55] (ERROR in xPDO\xPDOConnection::connect @ /home/olly/public_html/modx/public/core/vendor/xpdo/xpdo/src/xPDO/xPDOConnection.php : 89) SQLSTATE[HY000] [2019] Unknown character set 

I’ve looked at the server reqs and have the required php modules. Bit stuck!

Thank you for any tips, been a while since I used MODX, as an aside, great to be having some fun with it again… or it will be when I’ve managed to sort the db!

Cheers.

Can you check the file core/cache/setup/settings.cache.php to see what the value of “database_connection_charset” is?

I think at this stage in the installation it should always be utf8.

1 Like

ty halftrainedharry. Maybe I should mention that I created the database beforehand and am trying to link to that, although also I have tried to create the db using the MODX wizard but to no avail either.

Re settings.cache.php, I’m guessing the relevant elements in that array are these, so the charset is not being set?

  'database_dsn' => 'mysql:host=localhost;dbname=modxdev_005;charset=',
  'server_dsn' => 'mysql:host=localhost;charset=',

I studied the database using phpmyadmin and note that the collation says “utf8mb4_general_ci”. There appears to be no option to change to a “utf8” variant but various options for “utf8mb4” and others.

Maybe try just adding “charset=utf8” to these two settings in the settings.cache.php file by hand.
No idea why the charset is empty.
Creating the database beforehand is normal and “utf8mb4_general_ci” is a perfectly valid collation.

1 Like

Success!

Ran afresh, the wizard populated the settings.cache.php file and I altered from

 'database_connection_charset' => '',
  'database_charset' => '',`

to

  'database_connection_charset' => 'utf8',
  'database_charset' => 'utf8mb4',

and

Connecting to database server: Success! 

Thank you again halftrainedharry, very kind.
There’s no stopping me now. :smiley:

1 Like