mysqldump not creating create database syntax
Asked Answered
E

1

13

I am using mysql database. I am using mysqldump to create a dump of my database. I want the database to be dumped such that there is a drop database if exists command followed by create database command. I am using the following command (on my sample database project).

mysqldump --skip-comments --compact --add-drop-database -uroot -proot project

I am getting the following result:

CREATE TABLE `names` (
  `name` varchar(50) default NULL,
  `year` varchar(5) default NULL,
  `branch` varchar(50) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `names` VALUES ('Venkat','4-1','cse'),('rambabu','4-1','cse'),('nagesh','4-2','cse'),('ganesh','4-2','cse'),('rajesh','3-2','cse'),('ramesh','3-2','cse'),('sasirekha','3-1','cse'),('leela','3-1','cse');
CREATE TABLE `store` (
  `name` varchar(50) default NULL,
  `branch` varchar(50) default NULL,
  `year` varchar(50) default NULL,
  `feedback` varchar(500) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `store` VALUES ('nagesh','CSE','4-2','feedback for nagesh'),('ganesh','CSE','4-2','his performance is good. his behaviour is good.'),('rajesh','CSE','3-2','feedback of rajesh2'),('ramesh','CSE','3-2','feedback of ramesh'),('rajesh','CSE','3-2','feedback of rajesh'),('ramesh','CSE','3-2','feedback of ramesh'),('Venkat','CSE','4-1','feedback of venkat'),('rambabu','CSE','4-1','feedback of rambabu');

As you can see, i do not have the drop database and create database syntax here. What am i doing wrong?? MySqlServer ver: 14.12 Distrib 5.0.45

Empathize answered 10/2, 2012 at 5:25 Comment(3)
I hope you use that -p switch in only dev machine.Papilla
@shiplu.mokadd.im, whats so bad about using the -p?Patina
@Patina "that -p" is -proot which echos password and stays in bash history. Easy finding.Salot
C
24

try this: mysqldump --skip-comments --compact --add-drop-database -uroot -proot --databases project

Cavort answered 10/2, 2012 at 5:31 Comment(1)
Some might need the --lock-tables=False option #105112Epexegesis

© 2022 - 2024 — McMap. All rights reserved.