Php code: 01. & lt ;? Php02. & nbsp; 03. $ databasetest; // database name 04. & nbsp; 05. $ optionsarray (06. & nbsp; 07. & nbsp; hostname & gt; localhost, // IP address 08. & nbsp; 09. & nbsp; charset & g
Php code:
01.
02.
03.$ Database=Test;// Database name
04.
05.$ Options=Array(
06.
07.Hostname => Localhost,// IP address
08.
09.Charset => UTF-8,// Encoding
10.
11.Filename => $ Database.. SQL,// File name
12.
13.Username => Root,
14.
15.Password => 123123
16.
17.);
18.
19.Mysql_connect($ Options[Hostname],$ Options[Username],$ Options[Password])OrDie("Cannot connect to the database! ");
20.
21.Mysql_select_db($ Database)OrDie("The database name is incorrect! ");
22.
23.Mysql_query("SET NAMES{$ Options [charset]}");
24.
25.$ Tables =List_tables($ Database);
26.
27.$ Filename = Sprintf($ Options[Filename],$ Database);
28.
29.$ Fp = Fopen($ Filename, W);
30.
31.Dump_table(My_member, $ Fp); // Specify the name of the exported table or use the following statement to export the entire database
32.
33./*
34.
35. foreach ($ tables as $ table ){
36.
37. dump_table ($ table, $ fp );
38.
39 .}
40.
41 .*/
42.
43.Fclose($ Fp);
44.
45.// Download the SQL file
46.
47.$ File_name=$ Options[Filename];
48.
49.Header("Content-type: application/octet-stream");
50.
51.Header("Content-Disposition: attachment; filename =".$ File_name);
52.
53.Readfile($ File_name);
54.
55.// Delete the SQL file on the server
56.
57.Unlink($ File_name);
58.
59.Exit;
60.
61.// Obtain the table name
62.
63.FunctionList_tables($ Database)
64.
65.{
66.
67.$ Rs = Mysq