windows 区分大小写的mysqldump问题?赢-> linux
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2992079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysqldump problem with case sensitivity? Win->linux
提问by Martin Eve
When i dump a table with uppercase letters using mysqldump it comes out as lower case in my > dump.sql file. I found a report here in 2006, almost 4 years old http://bugs.mysql.com/bug.php?id=19967
当我使用 mysqldump 转储带有大写字母的表时,它在我的 > dump.sql 文件中显示为小写。我在 2006 年在这里发现了一个报告,快 4 岁了http://bugs.mysql.com/bug.php?id=19967
A solution heresuggest making linux insensitive. I rather not if possible. Whats the easiest way to copy a win32 db into linux?
这里的一个解决方案建议让 linux 不敏感。如果可能的话,我宁愿不要。将 win32 db 复制到 linux 的最简单方法是什么?
采纳答案by Lukasz Frankowski
Today I've had to make it so. I already have windows db in lower case and need to import to linux db with case sensitive table names, so the play with lowecase_table_names option in not an option :)
今天我不得不这样做。我已经有小写的 windows db,需要使用区分大小写的表名导入到 linux db,所以使用 lowecase_table_names 选项不是一个选项:)
It looks that 'show tables' displays appropriately sorted table names and the dump have escaped table names with ` character. I've succesfully imported the database with following algorithm:
看起来 'show tables' 显示了适当排序的表名,并且转储已经用 ` 字符转义了表名。我已经成功地使用以下算法导入了数据库:
- I have mydb.sql with lowercase windows dump
- I started application to create database schema in Linux, with case sensitive names.
- 我有带有小写 Windows 转储的 mydb.sql
- 我开始应用程序在 Linux 中创建数据库模式,名称区分大小写。
Then I've had lower case names in dump, and case sensitive names in mysql database. I converted the dump using sed & awk with following script:
然后我在转储中有小写名称,在 mysql 数据库中有区分大小写的名称。我使用 sed & awk 和以下脚本转换了转储:
#!/bin/bash
MYSQL="mysql -u root -p mydb"
FILE=mydb.sql
TMP1=`mktemp`
TMP2=`mktemp`
cp $FILE $TMP1
for TABLE in `echo "show tables" | $MYSQL`; do
LCTABLE=`echo $TABLE| awk '{print tolower(##代码##)}'`
echo "$LCTABLE --> $TABLE"
cat $TMP1 | sed "s/\`$LCTABLE\`/\`$TABLE\`/" > $TMP2
cp $TMP2 $TMP1
done
cp $TMP1 $FILE.conv
rm $TMP1
rm $TMP2
And the dump has been converted properly. Everything works after import in Linux.
并且转储已正确转换。在 Linux 中导入后一切正常。
回答by Martin Eve
According to the MySQL manuals, you only have a limited number of options:
根据 MySQL 手册,您只有有限数量的选项:
Use lower_case_table_names=1 on all systems. The main disadvantage with this is that when you use SHOW TABLES or SHOW DATABASES, you do not see the names in their original lettercase.
Use lower_case_table_names=0 on Unix and lower_case_table_names=2 on Windows. This preserves the lettercase of database and table names. The disadvantage of this is that you must ensure that your statements always refer to your database and table names with the correct lettercase on Windows. If you transfer your statements to Unix, where lettercase is significant, they do not work if the lettercase is incorrect.
Exception:If you are using InnoDB tables and you are trying to avoid these data transfer problems, you should set lower_case_table_names to 1 on all platforms to force names to be converted to lowercase.
在所有系统上使用lower_case_table_names=1。这样做的主要缺点是,当您使用 SHOW TABLES 或 SHOW DATABASES 时,您看不到原始字母中的名称。
在 Unix 上使用lower_case_table_names=0,在Windows 上使用lower_case_table_names=2。这保留了数据库和表名的字母大小写。这样做的缺点是您必须确保您的语句在 Windows 上始终使用正确的字母来引用您的数据库和表名称。如果你把你的语句转移到 Unix 上,在这种情况下,字母大写很重要,如果字母不正确,它们将不起作用。
例外:如果您正在使用 InnoDB 表并试图避免这些数据传输问题,您应该在所有平台上将 lower_case_table_names 设置为 1 以强制名称转换为小写。
See: http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.htmlfor full details.
有关完整详细信息,请参阅:http: //dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitive.html。