Symptoms
You are attempting to import a MySQL database manually, and getting errors regarding "Table already exists," whereas your newly created database is empty.
Description
Depending on how the database was exported, it may include another database name in the SQL dump this can cause errors when trying to import directly into a database since the SQL dump will either attempt to or create that database depending on the database users grants.
Workaround
Examine the .sql file with a text-based editor, and look for commands that look like this:
Example (not-working):
File: /backup/mysql/cptest.sql
Contents:
--
-- Database: `cptest_another-database`
--
CREATE DATABASE IF NOT EXISTS `cptest_another-database` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `cptest_another-database`;
When you import the database, MySQL executes the MySQL commands, which changes which database to use.
In this case, the workaround would be to change the database names inside the .sql file to match the database you want to create.
Example (fixed):
File: /backup/mysql/cptest.sql
Contents:
--
-- Database: `cptest_cptest1`
--
CREATE DATABASE IF NOT EXISTS `cptest_cptest1` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `cptest_cptest1`;