首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法更改PHP MySQLi连接的字符集

问无法更改PHP MySQLi连接的字符集
EN

Stack Overflow用户
提问于 2017-02-16 14:58:54
回答 2查看 190关注 0票数 0

为什么在与我的服务器上的mysql客户端连接时,我可以运行"CHARSET utf8mb4“并更改连接的字符集,但是当我尝试通过mysqli执行相同的语句时,它会给出以下错误:

在"charset utf8mb4“中出错;在SQL语法中有错误;检查与MariaDB服务器版本相对应的手册,以获得在第1行”charset utf8mb4“附近使用的正确语法。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-02-16 15:06:47

据我所知,MySQL服务器也没有任何charset命令。您可以使用集名指定字符集,这是设置几个相关变量的捷径(所有这些变量都可以使用SET命令设置)。

您可能混淆了官方命令行客户机的命令:

代码语言:javascript
复制
mysql> \h

For information about MySQL products and services, visit:
   http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
   http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
   https://shop.mysql.com/

List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear the current input statement.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
notee     (\t) Don't write into outfile.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.

由于您使用的是PHP,而不是命令行客户端,所以它不存在。

当然,mysqli设置编码的方法是字符集()。

票数 1
EN

Stack Overflow用户

发布于 2017-02-16 15:10:01

可以在连接到数据库时使用SET CHARACTER SET utf8mb4;语句。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42277493

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档