MariaDB default charset

9.5k Views Asked by At

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.

2

There are 2 best solutions below

0
On

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/)

0
On

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';