Skip to content

Instantly share code, notes, and snippets.

@bmvakili
Created May 14, 2015 20:08
Show Gist options
  • Save bmvakili/fad2a26ec830678d3c17 to your computer and use it in GitHub Desktop.
Save bmvakili/fad2a26ec830678d3c17 to your computer and use it in GitHub Desktop.
Problem import dump from Win to linux
#!/bin/bash
# Problem import dump from Win to linux
# Win mysql tables lowercase; and case insensitive as the default
# LInux mysql tables have case; and are case sensitive as the default
# So dumping from Win to Linux breaks things
# This script needs reference schema with case; it will use that to convert the dump file
# I have tested this with Liferay 6.2; ubuntu version 14.04
# This file is based on answer by l0co on StackOverflow
# http://stackoverflow.com/questions/2992079/mysqldump-problem-with-case-sensitivity-win-linux
#
#PortalSchemaWithTablesWithCorrectNames is the database containing correct cases
#mysqlDumpFileFromWindowsWithLowerCaseTableNames.sql is the dump file you took from Windows - it will be copied to mysqlDumpFileFromWindowsWithLowerCaseTableNames.sql.conv with correct cases
MYSQL="mysql -u liferay -p PortalSchemaWithTablesWithCorrectNames"
FILE=mysqlDumpFileFromWindowsWithLowerCaseTableNames.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment