This issue happens when I perform “quick export” to acquire a database backup of the Drupal website, and attempts to import it via the “mysql” command (or ahoy import
or ddev import-db
command):
Solution-1: use custom method to export database
Use custom method to export database, and check “Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGER statement” toggle before clicking “export” at the bottom.
Re-import using the newly exported database after toggling on “Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGER statement” function, and the issue should be gone.
Solution-2: empty database before import
If you already have the database (and cannot re-export it), this solution will be for you. You will need to “drop all the tables” and import to the clean, purged database.
To delete the tables, you can do it via phpMyAdmin’s GUI interface by selecting all the table and click “drop” under “With selected:” and confirm the deletion:
(alternatively, through terminal command: mysql -u USERHERE -pPASSWORDHERE --silent --skip-column-names -e "SHOW TABLES" DATABASENAMEHERE | xargs -L1 -I% echo 'SET FOREIGN_KEY_CHECKS = 0; DROP TABLE%; SET FOREIGN_KEY_CHECKS = 1;' | mysql -u USERHERE -pPASSWORDHERE -v DATABASENAMEHERE
Then re-import, and you won’t be seeing the issue anymore !