DEV Community


MariaDB: Update database charset / collation

Heddi Nabbisen
An ICT designer/developer and a security monk with "a cool brain and a warm heart". OpenBSD/Rust etc. Interested in social issues and relationships. Founder of Scqr Inc.
・1 min read

I made a mistake when I made a MariaDB database for a WordPress website.

The website would use Japanese and therefore the database charset should have been set "utf8mb4" as. I, however, did CREATE DATABASE without specific options and so it was "c" instead of "utf8mb4" unfortunately.

I updated its charset and collation with this SQL:

-- accessing through `mysql -u <user> -p`
ALTER DATABASE <database> \
    CHARACTER SET='utf8mb4' \
    COLLATE='utf8mb4_unicode_ci' \
Enter fullscreen mode Exit fullscreen mode

Well, it is also able to get charsets via SQL:

    FROM information_schema.SCHEMATA;
Enter fullscreen mode Exit fullscreen mode


Discussion (0)