Home >Database >Mysql Tutorial >Mysql插入中文变为全问号???的问题_MySQL

Mysql插入中文变为全问号???的问题_MySQL

WBOY
WBOYOriginal
2016-06-01 13:29:501108browse

bitsCN.com

Mysql插入中文变为全问号???的问题

 

1、检查并修改mysql的my.ini的配置文件

 

[mysql]default-character-set=utf8

 

 

2、建立数据库是要指定字符集

 

create database mydb default character set utf8 collate utf8_general_ci;

 

 

3、建立数据表示也要指定字符集:

 

出问题的命令:CREATE TABLE IF NOT EXISTS `mydb` (  `username` varchar(64) NOT NULL,  `userid` int(11) NOT NULL, ) ENGINE=InnoDB DEFAULT CHARSET=latin1;正确的命令:CREATE TABLE IF NOT EXISTS `mydb` (  `username` varchar(64) NOT NULL,  `userid` int(11) NOT NULL, ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 

 

 

说明:mysql版本:5.5.24

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn