Running environment: sae + thinkphp
DB_CHARSET is utf8; (setting it directly to utf8mb4 will report an error, I don’t know why...)
If you want to support emoji expressions, the test code is as follows
public function test(){
<code> $model = M(''); $model -> query('set names utf8mb4'); }</code>
Error message: [SQL statement]: set names utf8mb4.
Please give me some guidance, thank you!
Running environment: sae + thinkphp
DB_CHARSET is utf8; (setting it directly to utf8mb4 will report an error, I don’t know why...)
If you want to support emoji expressions, the test code is as follows
public function test(){
<code> $model = M(''); $model -> query('set names utf8mb4'); }</code>
Error message: [SQL statement]: set names utf8mb4.
Please give me some guidance, thank you!
<code>select version(); 看下数据库版本,5.5以上才支持utf8mb4 </code>
Mysql::utf8mb4
1. Check the version of mysql;
Mysql 5.5.3 and later versions add the utf8mb4 character set; previous versions need to upgrade the mysql server first.
2. MySQL utf8mb4 character set
Modify /etc/my.cnf
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
Restart MySQL Server and check the character set