I need to rename my database and figured out that by creating new DB and renaming the tables to new DB name, it is possible to rename DB
I followed the Renaming Tables with InnoDB section of https://chartio.com/resources/tutorials/how-to-rename-a-database-in-mysql/ link.
But many my tables have before_create triggers. This raises ERROR Trigger in wrong schema during the execution of the following command:
$ mysql -u dbUsername -p"dbPassword" catalog -sNe 'show tables' | while read table; do mysql -u dbUsername -p"dbPassword" -sNe "RENAME TABLE catalog.$table TO library.$table"; done
This issue is even mentioned in the MySql documentation - https://dev.mysql.com/doc/refman/5.7/en/rename-table.html
How can I go about renaming such tables?
you can copy database to new database and then drop it look at https://dev.mysql.com/doc/refman/5.7/en/mysqldump-copying-database.html