Hi

Does anyone know what is the simplest way to backup a database using the mysqldump function in php?


I have googled a lot and the codes i have found are very hard to understand and most of them does not work.

Thanx in advance for your help.

Recommended Answers

All 8 Replies

If you are allowed to use exec() then that will make it a one line script. Otherwise you can't access mysqldump directly through PHP.

and how about restoring the db?

If you are allowed to use exec() then that will make it a one line script. Otherwise you can't access mysqldump directly through PHP.

... or system() :cool:

Backup :

$command = "mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]";

Restore :

$command = "mysqldump -u [username] -p [password] [databasename] < [backupfile.sql]";
system($commmand);

- Mitko Kostov

this is nice one a really learn from it

Pritaeas, you are rigth. My bad.

- Mitko Kostov

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.