-
Notifications
You must be signed in to change notification settings - Fork 24.4k
[11.x] Changing DB_COLLATION #6367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
SQLSTATE[HY000]: General error: 1273 Unknown collation: 'utf8mb4_0900_ai_ci' (Connection: mysql, SQL: select table_name as `name`, (data_length + index_length) as `size`, table_comment as `comment`, engine as `engine`, table_collation as `collation` from information_schema.tables where table_schema = 'crm' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)
I believe you are using MySQL 5.7? |
@imariusalin what DB version are you using? |
mariadb Ver 15.1 Distrib 10.11.6-MariaDB, for Linux (x86_64) using readline 5.1 and tested on mysql 8.0 also |
@imariusalin seems highly unlikely that this is failing for the mentioned engine versions since our test suites test these versions. You're 100% sure you're not running MySQL 5.7? |
Yes, I'm sure. Plus, on my Windows machine, I'm using MariaDB 10.4.32. To replicate what I did, I installed it with laravel new project, followed all the steps, and, by default, it chose SQLite for some reason, even though I chose MySQL. Then, I went into the .env file, set up my database details, and tried to run php artisan migrate. |
Wouldn't it be better to use |
True, the solution worked for MariaDB, but I'm facing the same error on my Windows machine. Another complication is that, by default, not everyone knows the exact version of the software they're using, which leads to this error. Moreover, not many people know how to fix it. If you search online, you'll find that many people have encountered this issue. |
Just as a suggestion, I think it is good to have a default DB_COLLATION that will work on most of the systems and not cause an issue, and for those who want to use another DB_COLLATION i am pretty sure they already know how to handle this. |
@imariusalin I don't understand. You're using the MYSQL connection for MariaDB while there is a MariaDB connection? Does the issue also happen for you if the MariaDB connection? It seems not from your posts above but want to double check. |
It happend on Windows using mariadb driver from xampp. On linux after i have changed the driver type it worked. |
In the first image it says As for your original report shows, that you tried to use a MySQL 8 Collation on either a MySQL 5.7 or MariaDB database. (Like @driesvints and @crynobone said) MySQL 8: Older and replaced with the above: |
The issue happens if you don't know what type of DB you are using. In the screenshots, I'm using Windows 11 with XAMPP and MariaDB 10.x with the correct driver. On my Linux machine, I had MariaDB Ver 15.1 Distrib 10.11.6-MariaDB, but the driver was set wrong to MySQL and gave the error. Some MariaDB/mysql versions still don't have this DB_COLLATION, and it gives the issue on the first install. |
Maybe instead of changing the default collation, it would be better to show a reasonable error, like: It seems you are using MariaDB and also try to use a MySQL 8.0 only collation, we recommend changing the driver to mariadb or change the collation at your own risk Or show what Database Version you are using, so that it is easier debugable. |
There is some error in mariadb default config: New default laravel config while setting mariadb uses by default DB_COLLATION: utf8mb4_uca1400_ai_ci There is only "uca1400_ai_ci" New default laravel config:
also It's only present from 23.07 Enterprise. I suggest go for utf8mb4_unicode_ci |
It seems in the future MariaDB wants to use the short name You can see this on the following site: in the sections
This is only the display value (probably can also be used), but the long name with the charset prefix is still available. (The naming change probably happened after the merge of laravel/framework#48455 because in the discussion there was already the name in use.) Maybe @grooverdan can say something, as he works for MariaDB and probably knows more. |
There was wrong assumption for MariaDB version:
So wrong version assumtion (10.11+) or we have wrong info in docs: |
It seems the supported mariadb versions were reverted in the docs with laravel/docs#9113 I also did the PR with 10.11+ in mind. |
What is the actual solution here @Jubeki |
XAMPP is often used with Windows and the only alternative would be Laragon (which uses MySQL 5.7 so a similar Problem). MariaDB 10.4, 10.5 and 10.6 are still supported for up to two years (see https://endoflife.date/mariadb). There are two options in my opinion without reverting the default collation to the older one:
I would have loved to recommend Laravel Herd when it is released for Windows, but the database service is only available in the PRO version. |
@Jubeki can we just revert the MariaDB collation back to what it was for Laravel 10, or use |
|
Thanks - let me know |
@taylorotwell Switching to null is not an option, because it will result in Laravel 10 used It would be interesting to know, what people use in production and/or local development. Note This PR currently reverts the collation for MySQL and for MariaDB. |
So can I update just the MariaDB configuration to |
Updated MariaDB default. |
@taylorotwell If many people are still using MySQL 5.7 (not sure) than the same problem will happen again. Maybe it is best to revert both configurations for Laravel 11, and already announce or plan for Laravel 12, that older databases will be dropped? |
Let's wait to see if we get issues with the 5.7 thing. |
I see If the docs states that Laravel 11 supports MySQL 5.7+ OOTB, it is better to revert it too. |
Yep, XAMPP (ApacheFriends/xampp-build#17) appears to be moving slowly. and Laragon development appears to have stalled.
Technically multiple character sets, but yes, short names ensure accidental character set miss-match doesn't occur.
I did some prototype wordpress work on pulling a modern collation from what was available here: grooverdan/wordpress-develop@86500d3#diff-101f4101613ae810fc8e54675d9437f9aed83f89dfe2bd3068b2ed2964eece03R896-R938 (that I should get back to, feel free to use). Apart from that, not much I can add that you haven't covered already, uca1400 isn't accessible on < 10.10.1 MariaDB versions. |
Thanks @grooverdan. Appreciate the feedback 👍 |
Tested on windows & nixos. On default installation this error persists.
SQLSTATE[HY000]: General error: 1273 Unknown collation: 'utf8mb4_0900_ai_ci' (Connection: mysql, SQL: select table_name as
name, (data_length + index_length) as
size, table_comment as
comment, engine as
engine, table_collation as
collationfrom information_schema.tables where table_schema = 'crm' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)
Changing the DB_COLLATION to utf8mb4_unicode_ci fixes the issue!