Home > Software engineering >  mysql/mariadb import sql file, comments not imported
mysql/mariadb import sql file, comments not imported

Time:09-22

I've got an SQL file that I export which contains the structure, stored procedures and data. I'm developing a C application that I use to create the exported file, it now has an import feature, however when I import the data with:

mysql --host=localhost --user=trainer --password=Secret <trainer.sql

The SQL file contains comments in the stored procedures, these comments are within the BEGIN - END scope, but when the import has completed and I look at the database (using HeidiSQL) I can see blank areas where the comments should be but no comments.

I've searched online for this and the only thing I could see was a mention to ensure the comments are within the BEGIN - END scope which they are.

The database is MariaDB 10.5.9.0, running on Windows 10. If I use HeidiSQL to import the same file it works perfectly and the comments are present so it has to be something I've omitted.

CodePudding user response:

By default the mysql client ignores all comments in SQL. Use the -c or --comments flag to include them.

-c, --comments Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments.

  • Related