I want to connect with mysql database but here show the error like this
at vendor\laravel\framework\src\Illuminate\Database\Connection.php:813
809▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
810▕ );
811▕ }
812▕
➜ 813▕ throw new QueryException(
814▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
815▕ );
816▕ }
817▕ }
1 vendor\laravel\framework\src\Illuminate\Database\Connectors\MySqlConnector.php:121
PDOException::("SQLSTATE[HY000]: General error: 1273 Unknown collation: 'utf8mb4_0900_ai_ci'")
2 vendor\laravel\framework\src\Illuminate\Database\Connectors\MySqlConnector.php:121
PDO::exec("SET NAMES 'utf8mb4' COLLATE 'utf8mb4_0900_ai_ci', SESSION sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';")
Connect with mysql database of laravel 11 but show the error
In case if you are on a fresh installation of Laravel 11, there are some changes that had not been mentioned on the upgrade docs. One of these changes is that now the default Session driver is the
databasesession driver instead of thefilesession driver. So you will need to revert it from your.envfile to use the file driver:And/Or, if you want to keep using
databasesession driver as the default driver, and if you do not use MySQL 8.0, another change had been done in Laravel 11 and may break your application - in case if you're still using MySQL 5.7 - and I do not see that it is documented anywhere is that now the new default MySQL collation isutf8mb4_0900_ai_ciinstead ofutf8mb4_unicode_ci, this is according to that Laravel 11 now is using SQLITE as default database driver as mentioned. To solve this, you may need to add this env variable to your.envfile:Or whatever the collation you need.