Issue
- You might encounter the following error or similar during the upgrade process if your database's collation differs from the collation of the tables:
com.liferay.portal.kernel.upgrade.UpgradeException: java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='
at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:136) ~[portal-kernel.jar:?]
at com.liferay.portal.upgrade.internal.executor.UpgradeExecutor._executeUpgradeInfos(UpgradeExecutor.java:198) ~[bundleFile:?]
at com.liferay.portal.upgrade.internal.executor.UpgradeExecutor.executeUpgradeInfos(UpgradeExecutor.java:144) ~[bundleFile:?]
at com.liferay.portal.upgrade.internal.executor.UpgradeExecutor.execute(UpgradeExecutor.java:116) ~[bundleFile:?]
at com.liferay.portal.upgrade.internal.registry.UpgradeStepRegistratorTracker$UpgradeStepRegistratorServiceTrackerCustomizer.addingService(UpgradeStepRegistratorTracker.java:184) [bundleFile:?]
at com.liferay.portal.upgrade.internal.registry.UpgradeStepRegistratorTracker$UpgradeStepRegistratorServiceTrackerCustomizer.addingService(UpgradeStepRegistratorTracker.java:126) [bundleFile:?]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) [org.eclipse.osgi.jar:?]
Environment
- Liferay DXP 7.0+
- Upgrades
Resolution
- The issue occurs when importing dumps in a new database before Liferay Upgrade. After importing the data, you can check if there is any Collation mismatch (MySQL):
USE lportal;
# Check the database
SELECT @@character_set_database, @@collation_database;
# Check all the tables
SHOW TABLE STATUS; - If you find any differences between table and its database, you will need to do one of this options:
- For explanation purposes, there will be a database A with collation utf8mb4_0900_ai_ci, and a database B with collation utf8mb4_general_ci. The dump is exported from database A and imported in database B.
-
Option 1: Keep the collation of database A
- It is usually the easiest option.
- Before running any upgrade, you will need to update Database B:
ALTER DATABASE lportal CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
- Run the upgrade as normal.
-
Option 2: Keep the collation of database B
- Before running any upgrade, you will need to alter every table imported in the database B.
ALTER TABLE `account_` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE `address` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE ...
... - Run the upgrade as normal.
- Before running any upgrade, you will need to alter every table imported in the database B.
- If you have any doubt in which collation you may choose, create a new support ticket with your enterprise subscription.