Click to See Complete Forum and Search --> : MySQL: How To use mysqldump pratically


cancer10
09-25-2008, 05:49 AM
Hi,

I am runnning MySQL Server v 5.0 on my local machine which has Windows XP Pro SP2 installed.

I have a database "mydb" and I am trying to make use of the mysqldump command since the past 2 days (taking help from mysql.com as well as google)

I have gone through the tutorial http://www.devarticles.com/c/a/MySQL/Backing-Up-Your-MySQL-Databases-With-MySQLDump/

but still unable to see how to make use of it. This is the command I am running in the MySQL Command Line.

mysqldump --host=localhost –-user root –-password=toor mydb > sql.dump

but getting the following error

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'mysql
dump --host=localhost --user root --password=toor mydb > sql.dump' at line 1

Please help

chazzy
09-25-2008, 07:09 AM
you run mysqldump from command line, not from inside of the mysql client program. it should be something like


c:\> mysqldump --host=localhost --user=root --password=toor mydb > mydb.sql

cancer10
09-25-2008, 07:11 AM
Works like a charm!!!

Is there a restore command also?


please share

Thanx

cancer10
09-25-2008, 07:18 AM
Any idea why do I get this error when I am trying to execute it via PHP?

Warning: system() [function.system]: Unable to fork [mysqldump -uroot -ptoor mydb > testdump.sql] in C:\apache\htdocs\mysqldump.php on line 2

I am using this PHP command

<?php
system('mysqldump -uroot -ptoor mydb > testdump.sql');
?>

cancer10
09-25-2008, 07:27 AM
I googled and read this article

http://www.somacon.com/p255.php


I fixed it :)

Thanx

cancer10
09-25-2008, 08:02 AM
All done.

But the sql file now being created via PHP is just blank.

whereas if I run the mysqldump command from command line then it works like a charm.

Any idea wots going on?

cancer10
09-25-2008, 08:44 AM
Ok i got the solution to this.

when I was trying to execute the mysqldump command through PHP, it was expecting the mysqldump.exe to be in teh same directory where the mysqldump.php file is.

So what all I did is, I copied the mysqldump.exe file from "C:\Program Files\MySQL\MySQL Server 5.0\bin" into the directory where I have the mysqldump.php file.

Which did the trick :)

May be this will be of some help for people looking for similar issues.


Thanx