I originally wrote a project using thinkphp5. In order to solve the emoji problem, the database character set used utf8mb4, which ran well on the server at that time. Recently due to some reasons it was necessary to transfer the entire system to a new server. However, after importing the original database and deploying the system, when trying to run it, the message Can't initialize character set utf8mb4
appears over and over again. .
Some of the attempts I have made so far (although I haven’t dealt with it yet, but I think other people can learn from some ideas)
Check your php system database connection information, it is normal
Check the server version. It was first found that 5.5.2 was installed, and the MySQL version requirement that supports utf8mb4 is >=5.5.3. After the upgrade, the problem remains
Modifymy.cnf
to make utf8mb4 the default character set for connections (you can refer to this article), the problem remains
Try to run the server-side mysql clientSET NAMES utf8mb4
, and it successfully runs in the mysql client, but the problem remains
Try to modify the character set of the corresponding library, but the problem remains (But I have to say that I feel that this is useless, suggesting that this should be stuck in connection rather than access)
I have tried the above, but the problem still remains. I don’t know if you have any guidance?
迷茫2017-06-13 09:23:30
If you are still on version 5.5, you need to re-cmake or specify the character set directory. Official documentation on this issue: https://dev.mysql.com/doc/ref...