PHP Code Export Database - Php

How to export database using PHP code?

Snippet Code


  
Rate this page :
  [ 0 votes]

This php code "mysqldump -h" command is used to export your database which will be saved as .sql format. Wherever you need to use this database, just import ".sql" file.

<?php //Fill the below information $dbname ='ajaxvoting';//your dbname $username ='root';//your username $password ='';//your password $hostname ='localhost';//your hostname $exportpath ="mydb.sql";//your export path $command='/usr/local/bin/mysqldump -h ' .$hostname .' -u ' .$username .' ' .$dbname .' > ' .$exportpath; echo $command; exec($command); ?>

Tags


Ask Questions

Ask Question