Sample Header Ad - 728x90

How can I prevent mysqldump from prepending the database name in CREATE VIEW?

2 votes
2 answers
569 views
When I execute the following: mysqldump -u root -n mydatabase > mydatabase.sql The tables are all dumped without the database name, but the views oddly get the database name prepended: /*!50001 DROP TABLE IF EXISTS vfiscalperiodcombobox*/; /*!50001 DROP VIEW IF EXISTS vfiscalperiodcombobox*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8 */; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=root@localhost SQL SECURITY DEFINER */ /*!50001 VIEW mydatabase.vfiscalperiodcombobox AS select mydatabase.fiscalperiod.name AS text,mydatabase.fiscalperiod.id AS value from mydatabase.fiscalperiod order by mydatabase.fiscalperiod.start */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; Because of this I cannot import this file into another database (without manually removing the database names from the file). This happens with the following MariaDB version on Windows: mysql Ver 15.1 Distrib 10.1.9-MariaDB, for Win32 (AMD64) It does NOT happen with the following version on Debian: mysql Ver 15.1 Distrib 10.0.28-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2 Is this simply a bug? Or am I doing something wrong? Or is there a flag with which I can force mysqldump to never prepend the database name?
Asked by user115578 (21 rep)
Jan 21, 2017, 04:51 PM
Last activity: Apr 19, 2022, 09:39 AM