Is it possible to export the database with .sql Extension using PHP code?
Example
database name: demodb
DB contains two tables
table one: user
table two: registration
Yes Its possible .
<?php
//ENTER THE RELEVANT INFO BELOW
$mysqlDatabaseName ='xxxxxx';
$mysqlUserName ='xxxxxxx';
$mysqlPassword ='myPassword';
$mysqlHostName ='xxxxxxxx.net';
$mysqlExportPath ='chooseFilenameForBackup.sql';
//DO NOT EDIT BELOW THIS LINE
//Export the database and output the status to the page
$command='mysqldump --opt -h' .$mysqlHostName .' -u' .$mysqlUserName .' -p' .$mysqlPassword .' ' .$mysqlDatabaseName .' > ~/' .$mysqlExportPath;
exec($command);
?>
use mysqldump command for mySql db:
$command = "/usr/bin/mysqldump -u mysql_username -h mysql_host -p mysql_password database_name> /path_to_export_location/file_name.sql";
exec($command, NULL, NULL);
make a look at documentation in MySQL
CREATEandINSERTstatements with your PHP code and put into your SQL file.