Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysqldump not creating create database syntax

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

like image 694
sasidhar Avatar asked Feb 10 '12 05:02

sasidhar


People also ask

Does Mysqldump create database?

Mysqldump is a command-line utility that is used to generate the logical backup of the MySQL database. It produces the SQL Statements that can be used to recreate the database objects and data. The command can also be used to generate the output in the XML, delimited text, or CSV format.

Why Mysqldump is not working?

If mysqldump is not identified by the cmd prompt that means it cannot recognize where the mysqldump.exe is located. You need to add path of the directory where the exe is located in the PATH variable under environment variables. After doing that your command will start working in the cmd prompt.


1 Answers

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

like image 130
Brian Papantonio Avatar answered Oct 03 '22 07:10

Brian Papantonio