Reputation: 378
I am generating a dump file form mysql using mysqldump -u root -p --databases dbname > dump.sql
, and the file generated is as follows:
-- MySQL dump 10.13 Distrib 8.0.21, for osx10.15 (x86_64)
--
-- Host: localhost Database: dbname
-- ------------------------------------------------------
-- Server version 8.0.21
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Current Database: `dbname`
--
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `dbname` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `dbname`;
--
-- Table structure for table `tbname`
--
DROP TABLE IF EXISTS `tbname`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tbname` (
`volume_no` int NOT NULL,
`issue_no` int NOT NULL,
`page_no` int NOT NULL,
`category` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL,
`title` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
PRIMARY KEY (`volume_no`,`issue_no`,`page_no`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
But this has many comments and info which I don't exactly need. Is there a way to directly get output without things like /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
etc. as despite being comments, these are generating errors when the file is executed from a python
Upvotes: 2
Views: 1849
Reputation: 30545
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
aren't really comments even though they look that way. They are conditional-execution tokens.
however you can skip comments by --skip-comments
and you can try --compact
as well
Upvotes: 7