1

Dumped sql from MySQL is showing inconsistencies in the name of the database.

Using the following bog standard method to dump a database:

mysqldump --add-drop-database -u someuser --databases Geo-ASty

I get the following output:

...
/*!40000 DROP DATABASE IF EXISTS `Geo-ASty`*/;

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `geo-asty` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;

USE `Geo-ASty`;
...

Note the case for the database which changes for the CREATE DATABASE statement. I kid you not.

I wouldn't care if it worked but importing this sql back in causes errors:

ERROR 1049 (42000) at line 26: Unknown database 'Geo-ASty'

I'm using MySQL 5.5 and exporting from a Mac.

2
  • Are you importing data from Linux to Windows ? Commented Jul 22, 2014 at 18:20
  • @RolandoMySQLDBA No, Mac to Linux. Will edit the question.
    – zaf
    Commented Jul 23, 2014 at 6:46

1 Answer 1

1

Set lower_case_table_names=1 on the Linux server before importing, this will convert all databases to lower case and new queries will use lower case, too. You can see it here.

Your problem arises from the fact that the default value on Mac is 2 (names are not case sensitive when queried, but they are when stored) but 0 on Unix/Linux (names are always case sensitive). This is because entities like tables and databases names depend on ON files and directories, which have different properties on different systems.

To avoid further problems I would recommend you following a standard (usually, only using lower case identifiers for tables, databases and aliases -column names are always case insensitive) and stick to it.

2
  • Thanks. That is really annoying. Can you explain to me why mysqldump would use lower case for the "CREATE DATABASE" and the correct case for the other statements?
    – zaf
    Commented Jul 23, 2014 at 8:13
  • As far as I am concerned, this was considered not a bug by the developers: bugs.mysql.com/bug.php?id=33898 Not many people care because most of us know the case insensitive problem between systems -that is, like the newline character, not a MySQL problem, is an OS incompatibility- and always use lower case/configure the aforementioned variable and go on.
    – jynus
    Commented Jul 23, 2014 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.