我将MYSQL数据库安装在LINUX下,我现在要向表中插入数据,我插入的数据是中文的,
比如张三,21,男、河北张家口这样的。可是在MYSQL数数库中无法打中文啊,这怎么办啊,请高手说一下...
比如 张三,21,男、河北张家口这样的。可是在MYSQL数数库中无法打中文啊,这怎么办啊,请高手说一下
展开
展开全部
1、你在什么地方进行操作?
2、编码是什么?
你最好装一个 phpmyadmin ,当然这还需要服务器上跑 apache + php (反正只要是能跑 php 网站就行)。用 phpmyadmin 操作很方便。如果你不想这么弄,那么一定要在图形界面里面用中文环境运行 mysql 命令解释器进行字符操作,纯字符界面的中文和编码支持不够好。图形界面的模拟终端窗口可以设置编码,一定要把这里的编码和你的数据库设置一致,并且在运行 mysql 解释器之前,先用 export LANG=xxxxx.xxxx 设置和数据库数据一样的编码。不然乱码后会更加混乱。而且图形界面的中文输入法也比字符界面的好用。
这两种方式都支持中文,但绝对要注意编码!
2、编码是什么?
你最好装一个 phpmyadmin ,当然这还需要服务器上跑 apache + php (反正只要是能跑 php 网站就行)。用 phpmyadmin 操作很方便。如果你不想这么弄,那么一定要在图形界面里面用中文环境运行 mysql 命令解释器进行字符操作,纯字符界面的中文和编码支持不够好。图形界面的模拟终端窗口可以设置编码,一定要把这里的编码和你的数据库设置一致,并且在运行 mysql 解释器之前,先用 export LANG=xxxxx.xxxx 设置和数据库数据一样的编码。不然乱码后会更加混乱。而且图形界面的中文输入法也比字符界面的好用。
这两种方式都支持中文,但绝对要注意编码!
展开全部
进入安装目录下的 my.ini修改配置,
有两个地方需要修改,一个是client端的还有一个是server端的
Sql代码
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]
port=3306
[mysql]
default-character-set=gbk//这个地方
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 6.0/"
#Path to the database root
datadir="C:/Program Files/MySQL/MySQL Server 6.0/Data/"
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=gbk//这个地方
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]
port=3306
[mysql]
default-character-set=gbk//这个地方
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 6.0/"
#Path to the database root
datadir="C:/Program Files/MySQL/MySQL Server 6.0/Data/"
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=gbk//这个地方
其实这两个地方弄好了,未必就能插入中文,
还要在创建数据库的时候 指定 default charset=gbk
创建表的时候最好也加上。这样保证你百分百不会在
报错了。
有两个地方需要修改,一个是client端的还有一个是server端的
Sql代码
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]
port=3306
[mysql]
default-character-set=gbk//这个地方
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 6.0/"
#Path to the database root
datadir="C:/Program Files/MySQL/MySQL Server 6.0/Data/"
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=gbk//这个地方
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]
port=3306
[mysql]
default-character-set=gbk//这个地方
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 6.0/"
#Path to the database root
datadir="C:/Program Files/MySQL/MySQL Server 6.0/Data/"
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=gbk//这个地方
其实这两个地方弄好了,未必就能插入中文,
还要在创建数据库的时候 指定 default charset=gbk
创建表的时候最好也加上。这样保证你百分百不会在
报错了。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我使用的是ubuntu的,可以打中文进去。 你可以换个成这样的啊。其他的 你看能不能找到linux的中文输入法吧。我觉得这个不关数据库的事情 如果linux可以输入中文字的话,数据库肯定支持的。char字符就ok了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |