mysqldump问题是否区分大小写? Win-> Linux [英] mysqldump problem with case sensitivity? Win->linux

查看:350
本文介绍了mysqldump问题是否区分大小写? Win-> Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用mysqldump转储带有大写字母的表时,在我的> dump.sql文件中它以小写形式出现.我于2006年在这里找到了一份报告,将近4岁了 http://bugs.mysql. com/bug.php?id = 19967

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

一个此处的解决方案建议使Linux不敏感.我宁愿不行.将Win32数据库复制到Linux的最简单方法是什么?

A solution here suggest making linux insensitive. I rather not if possible. Whats the easiest way to copy a win32 db into linux?

推荐答案

今天,我不得不这样做.我已经有小写的Windows db了,需要使用区分大小写的表名导入到Linux db,所以不可以使用lowecase_table_names选项进行播放:)

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 :)

看起来显示表"显示适当排序的表名,转储使用`字符转义了表名.我已经使用以下算法成功导入了数据库:

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:

  1. 我的mydb.sql带有小写的Windows转储
  2. 我启动了应用程序以在Linux中创建数据库模式,并使用区分大小写的名称.

然后我在转储中使用了小写字母名称,而在mysql数据库中使用了区分大小写的名称.我使用sed&转换了转储用以下脚本awk:

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:

#!/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($0)}'`
  echo "$LCTABLE --> $TABLE"
  cat $TMP1 | sed "s/\`$LCTABLE\`/\`$TABLE\`/" > $TMP2
  cp $TMP2 $TMP1
done

cp $TMP1 $FILE.conv

rm $TMP1
rm $TMP2

转储已正确转换.在Linux中导入后一切正常.

And the dump has been converted properly. Everything works after import in Linux.

这篇关于mysqldump问题是否区分大小写? Win-> Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆