How can I make a SQL file with PHP that contains SQL script to create exact copy of my entire database. Like I can do it in PhpMyAdmin.
如何使用包含SQL脚本的PHP创建一个SQL文件来创建整个数据库的精确副本。就像我可以在PhpMyAdmin中做到的那样。
For example:
例如:
I have a database with few tabel and I would like PHP script to to return SQL script like:
我有一个几乎没有tabel的数据库,我希望PHP脚本能够返回SQL脚本,如:
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Database: `first_db`
--
-- --------------------------------------------------------
--
-- Structure of table `my_table`
--
CREATE TABLE IF NOT EXISTS `my_table` (
`id` int(11) NOT NULL,
`naslov` text COLLATE utf8_slovenian_ci NOT NULL,
`besedilo` text COLLATE utf8_slovenian_ci NOT NULL,
`datum` text COLLATE utf8_slovenian_ci NOT NULL,
`avtor` text COLLATE utf8_slovenian_ci NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_slovenian_ci;
--
-- Fill data for `my_table`
--
INSERT INTO `my_table` (`id`, `naslov`, `besedilo`, `datum`, `avtor`) VALUES
1 个解决方案
#1
0
just use exec() in php with the following shell command
使用以下shell命令在php中使用exec()
exec('mysqldump –u [user name] –p[password] [database name] > [dump file]');
dont forget that exec can be disabled in php.ini if it doesn't work
不要忘记,如果exec不起作用,可以在php.ini中禁用它
#1
0
just use exec() in php with the following shell command
使用以下shell命令在php中使用exec()
exec('mysqldump –u [user name] –p[password] [database name] > [dump file]');
dont forget that exec can be disabled in php.ini if it doesn't work
不要忘记,如果exec不起作用,可以在php.ini中禁用它