第二步在命令行先输入"use day14_customer",按回车键,进去数据库,注意最后一个分号,day14_customer是数据库名字,如下图所示:
第三步再输入“ show create database day14_customer”,查看数据库的编码方式
4
第四步修改数据库编码信息,输入“alter database day14_customer default character set gbk”
default-character-set=utf82单独设置某个数据库:alter
database
testdb
character
set
utf8
查看mysql支持的编码:
show
character
set也可以使用如下方法查看编码:
show
status
mysql
-uroot
use
your
database
status
----------------------------------
server
characterset:
utf8
db
characterset:
utf8
client
characterset:
utf8
conn.
characterset:
utf8
tcp
port:
3306
uptime:
53
sec
----------------------------------
如果
client
为utf8
,
改为:
set
char
set
'gbk'
查看数据库编码:show
create
database
your_db_name
需要以root用户身份登陆才可以查看数据库编码方式(以root用户身份登陆的命令为:>mysql -u root –p,之后两次输入root用户的密码),查看数据库的编码方式命令为:>show variables like 'character%'
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
从以上信息可知数据库的编码为latin1,需要修改为gbk或者是utf8;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)