MYSql – Ubuntu 20 – When importing DB, it gets duplicated in lowercase instead of writing to file

MySQLUbuntu

This is my first post here, I'm trying to import a DataBase.

I'm using Ubuntu with MySQL to run .net core app.

I've exported the Database in Windows MYSql WorkBench, uploaded the file to the server via FileZilla.

After creating the DB in MYSql, it appears as "WebApp3DB" after SHOW DATABASES; is run.

after importing the file with the command:

mysql -u root -p WebApp3DB < /home/ubuntu/netcoreapp/WebApp3DB.sql

The WebApp3DB db won't get updated with the tables and values, but a new DataBase is created with the name webapp3db (all lower case)and it has the tables and values inside.

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| WebApp3DB          |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| webapp3db          |
+--------------------+

Being so .net won't recognize it.
Please advise.

Best Answer

Edit server's configuration file, set lower_case_table_names parameter value in [mysqld] section to 2 (uncomment if commented, create if not exists), and restart server. See Identifier Case Sensitivity for details.

Remember, that this solution affects on all databases - but, as you show, this is the only user database on the server instance, so this method may be the best solution in your case.


Alternative solutions:

Open your WebApp3DB.sql file in some text editor and comment CREATE DATABASE and USE statements in it. Will fail if lower_case_table_names is set to zero, and database alias is added to tablenames specifications in backup queries.

Re-create the backup disabling "Insert database creation command" option.