Čamo
Čamo

Reputation: 4192

MariaDB default charset

Documentation for MariaDB says clearly how to set up server defaults like charset and collation. So I opened my Mariadb console and run:

SET character_set_server = 'utf8mb4';
SET collation_server = 'utf8mb4_slovak_ci';

Consoles wrote OK. Then I restart the server, but as I tried to create new database there are still the same latin2 charset and swedish collation. I do it automatically via Symfony cosole command

php bin/console doctrine:database:create

What is wrong with that? I did it like documentation says.

Upvotes: 2

Views: 12385

Answers (2)

Stanley Nguma
Stanley Nguma

Reputation: 306

First, run the SHOW VARIABLES like "%collation%"; to show you the current configs. To change collation_server setting, you have to use the keyword GLOBAL and therefore your statement will be SET GLOBAL collation_server = 'utf8mb4_slovak_ci';

Upvotes: 1

Georg Richter
Georg Richter

Reputation: 7526

SET character_set_server changes the character set for the current connection. SET global character_set_server changes the character set globally for each new connection.

However if you restart your server the default character sets for server will be read from the configuration file. If the configuration file doesn't specify character set, then defaults will be used. So for making your settings permanent, you have to change the character sets in your configuration file (https://mariadb.com/kb/en/configuring-mariadb-with-option-files/)

Upvotes: 3

Related Questions