Re-Create views, functions and triggers to avoid collation misma
A workflow often needed after database imports
MariaDB is very strict with mixed collations. When a function with a string modifier (like replace) was created in utf8_unicode_ci (default in phpMyAdmin) but the rest of the database uses utf8mb4_general_ci, you will get a mismatch error. Unfortunately, it is not possible to convert all functions or views to a new collation with a single command. Instread, it is easier to re-create them:
Views
- in phpMyAdmin: Database view
- Export custom, mark only views, only structure, SQL, enable DROP
- wipe out definers and incompatible charsets if imported from another database
- re-eimport with phpMyAdmin (as file or in the SQL textbox)
Routines (functions and procedures)
- Adjust USER, DATABASE and file path in the following statement and excecute in PowerShell in your MariaDB bin directory:
- .\mysqldump -u USER --default-character-set=utf8mb4 --no-data --no-create-info --routines --triggers --add-drop-trigger --events --result-file="routines.sql" "DATABASE"
- wipe out definers and incompatible charsets if imported from another database
- re-import
Triggers
Use the line
.\mysqldump -u USER --default-character-set=utf8mb4 --skip-comments --no-data --no-create-info --skip-events --triggers --add-drop-trigger --result-file="triggers.sql" "DATABASE"
Adjust the phpMyAdmin config file:
If you have access to config.inc.php (with xampp under c:/xampp/phpMyAdmin), you can add:
$cfg['DefaultConnectionCollation'] = 'utf8mb4_general_ci';