免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 9339 | 回复: 13
打印 上一主题 下一主题

mysql创建中文数据库名问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-05-11 11:26 |只看该作者 |倒序浏览
本人刚接触mysql,要做一个测试,需要创建中文数据库名。比如 mysql>create database 测试;
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| atempo             |
| mysql              |
| test               |
| 测试               |
+--------------------+
5 rows in set (0.17 sec)


mysql> show variables like 'character%';
+--------------------------+----------------------------------------------------
-----+
| Variable_name            | Value
     |
+--------------------------+----------------------------------------------------
-----+
| character_set_client     | gb2312
     |
| character_set_connection | gb2312
     |
| character_set_database   | utf8
     |
| character_set_filesystem | binary
     |
| character_set_results    | gb2312
     |
| character_set_server     | utf8
     |
| character_set_system     | utf8
     |
| character_sets_dir       | C:\Program Files\MySQL\MySQL Server 5.0\share\charsets\
|+--------------------------+---------------------------------------------------------+
8 rows in set (0.06 sec)

结果对应的数据库目录成了乱码,请问名位大虾这种情况怎么解决数据库文件目录名乱码问题?
例:C:\Program Files\MySQL\MySQL Server 5.0\data\娴嬭瘯

论坛徽章:
0
2 [报告]
发表于 2009-05-12 00:20 |只看该作者
自己顶!谁能帮我一下,多谢了!

论坛徽章:
9
技术图书徽章
日期:2014-10-14 15:48:13数据库技术版块每日发帖之星
日期:2015-06-04 22:20:00数据库技术版块每日发帖之星
日期:2015-06-10 22:20:00数据库技术版块每日发帖之星
日期:2015-06-11 22:20:00数据库技术版块每日发帖之星
日期:2015-06-13 22:20:00IT运维版块每日发帖之星
日期:2015-09-22 06:20:00IT运维版块每日发帖之星
日期:2015-12-08 06:20:00综合交流区版块每日发帖之星
日期:2016-02-02 06:20:00IT运维版块每日发帖之星
日期:2016-07-25 06:20:00
3 [报告]
发表于 2009-05-12 00:49 |只看该作者
原帖由 prettyhs 于 2009-5-11 11:26 发表
本人刚接触mysql,要做一个测试,需要创建中文数据库名。比如 mysql>create database 测试;
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| informatio ...


1、改MY.INI,设置客户端默认语言代码,试一下UTF-8和GB2312
2、create database 后面加参数,设置默认数据库CHARSET,反正不是UTF-8就是GB2312,不设置默认CHARSET,你以后建的表,名字也会是乱码。

论坛徽章:
0
4 [报告]
发表于 2009-05-12 12:28 |只看该作者

回复 #3 bbjmmj 的帖子

我在网上查到的说是,“我们可以完全无视数据库默认的字符集是什么,我们关心的只有数据库在建立的时候是不是加入了字符集选择。”
我用的是这条命令,
mysql> create database 测试 default character set utf8 collate utf8_general_ci;

数据库的目录还是乱码,使用数据库中文都没有问题,不知道为什么目录老是乱码?
数据库的目录还是“C:\Program Files\MySQL\MySQL Server 5.0\data\娴嬭瘯”

论坛徽章:
0
5 [报告]
发表于 2009-05-12 12:34 |只看该作者
原帖由 bbjmmj 于 2009-5-12 00:49 发表


1、改MY.INI,设置客户端默认语言代码,试一下UTF-8和GB2312
2、create database 后面加参数,设置默认数据库CHARSET,反正不是UTF-8就是GB2312,不设置默认CHARSET,你以后建的表,名字也会是乱码。



多谢你的回复啊,上个回复是对您的回复,能不能再帮我看看?
有没有大虾遇到过这个问题啊?

[ 本帖最后由 prettyhs 于 2009-5-12 12:40 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2009-05-12 22:04 |只看该作者
set names gbk;
or
set names utf8;
then
create database   .................;

论坛徽章:
9
技术图书徽章
日期:2014-10-14 15:48:13数据库技术版块每日发帖之星
日期:2015-06-04 22:20:00数据库技术版块每日发帖之星
日期:2015-06-10 22:20:00数据库技术版块每日发帖之星
日期:2015-06-11 22:20:00数据库技术版块每日发帖之星
日期:2015-06-13 22:20:00IT运维版块每日发帖之星
日期:2015-09-22 06:20:00IT运维版块每日发帖之星
日期:2015-12-08 06:20:00综合交流区版块每日发帖之星
日期:2016-02-02 06:20:00IT运维版块每日发帖之星
日期:2016-07-25 06:20:00
7 [报告]
发表于 2009-05-12 22:29 |只看该作者
原帖由 prettyhs 于 2009-5-12 12:28 发表
我在网上查到的说是,“我们可以完全无视数据库默认的字符集是什么,我们关心的只有数据库在建立的时候是不是加入了字符集选择。”
我用的是这条命令,
mysql> create database 测试 default character set u ...


create database中设置的语言编码,影响的是库里面的中文表名,如果你想创建中文名称的数据库,需要改MY.INI,试一下GBK\UTF8\GB2312三种编码。

数据迁移的时候,默认字符集是不能无视的。

论坛徽章:
0
8 [报告]
发表于 2009-05-13 01:02 |只看该作者
原帖由 cyscg 于 2009-5-12 22:04 发表
set names gbk;
or
set names utf8;
then
create database   .................;


谢谢你的回复, 我试了set names utf8;不让创建中文数据库名。
set names gbk; 可以创建,但问题依旧,还是原来的问题。

论坛徽章:
0
9 [报告]
发表于 2009-05-13 01:10 |只看该作者
原帖由 bbjmmj 于 2009-5-12 22:29 发表


create database中设置的语言编码,影响的是库里面的中文表名,如果你想创建中文名称的数据库,需要改MY.INI,试一下GBK\UTF8\GB2312三种编码。

数据迁移的时候,默认字符集是不能无视的。

我改了my.ini然后重启mysql还是问题依旧,我把my.ini的内容贴出来。 utf8 不让创建中文数据库名,gbk gb2312可以创建,但生成的数据库目录还是乱码。

# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
# (@localstatedir@ for this installation) or to
# ~/.my.cnf to set user-specific options.
#
# On Windows you should keep this file in the installation directory
# of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
# make sure the server reads the config file use the startup option
# "--defaults-file".
#
# To run run the server from the command line, execute this in a
# command line shell, e.g.
# mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# To install the server as a Windows service manually, execute this in a
# command line shell, e.g.
# mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# And then execute this in a command line shell to start the server, e.g.
# net start MySQLXY
#
#
# Guildlines for editing this file
# ----------------------------------------------------------------------
#
# In this file, you can use all long options that the program supports.
# If you want to know the options a program supports, start the program
# with the "--help" option.
#
# More detailed information about the individual options can also be
# found in the manual.
#
#
# 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 5.0/"

#Path to the database root
datadir="C:/Program Files/MySQL/MySQL Server 5.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

# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB

# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connections=100

# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
query_cache_size=32M

# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
table_cache=256

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
tmp_table_size=35M


# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
thread_cache_size=8

#*** MyISAM Specific options

# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_max_extra_sort_file_size=100G

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_sort_buffer_size=69M

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
key_buffer_size=50M

# Size of the buffer used for doing full table scans of MyISAM tables.
# Allocated per thread, if a full scan is needed.
read_buffer_size=64K
read_rnd_buffer_size=256K

# This buffer is allocated when MySQL needs to rebuild the index in
# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE
# into an empty table. It is allocated per thread so be careful with
# large settings.
sort_buffer_size=256K


#*** INNODB Specific options ***


# Use this option if you have a MySQL server with InnoDB support enabled
# but you do not plan to use it. This will save memory and disk space
# and speed up some things.
#skip-innodb

# Additional memory pool that is used by InnoDB to store metadata
# information.  If InnoDB requires more memory for this purpose it will
# start to allocate it from the OS.  As this is fast enough on most
# recent operating systems, you normally do not need to change this
# value. SHOW INNODB STATUS will display the current amount used.
innodb_additional_mem_pool_size=2M

# If set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise this safety, and you are running small
# transactions, you may set this to 0 or 2 to reduce disk I/O to the
# logs. Value 0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value 2
# means the log is written to the log file at each commit, but the log
# file is only flushed to disk approximately once per second.
innodb_flush_log_at_trx_commit=1

# The size of the buffer InnoDB uses for buffering log data. As soon as
# it is full, InnoDB will have to flush it to disk. As it is flushed
# once per second anyway, it does not make sense to have it very large
# (even with long transactions).
innodb_log_buffer_size=1M

# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
# row data. The bigger you set this the less disk I/O is needed to
# access data in tables. On a dedicated database server you may set this
# parameter up to 80% of the machine physical memory size. Do not set it
# too large, though, because competition of the physical memory may
# cause paging in the operating system.  Note that on 32bit systems you
# might be limited to 2-3.5G of user level memory per process, so do not
# set it too high.
innodb_buffer_pool_size=97M

# Size of each log file in a log group. You should set the combined size
# of log files to about 25%-100% of your buffer pool size to avoid
# unneeded buffer pool flush activity on log file overwrite. However,
# note that a larger logfile size will increase the time needed for the
# recovery process.
innodb_log_file_size=20M

# Number of threads allowed inside the InnoDB kernel. The optimal value
# depends highly on the application, hardware as well as the OS
# scheduler properties. A too high value may lead to thread thrashing.
innodb_thread_concurrency=8

log-bin=mysql-bin

论坛徽章:
0
10 [报告]
发表于 2009-05-13 01:36 |只看该作者
彻底无语了,重装了一遍mysql,在配置实例向导过程中,在语言那一页选第三项, 直接指定默认语言为gbk(这回肯定默认字符集肯定为中文了),再次测试还是那个乱码目录。。。。。
C:\Program Files\MySQL\MySQL Server 5.0\data\娴嬭瘯
我觉得应该和default charset 没关系了。。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP