-
Copy Code------Answer--------The second one has not been done, follow this issue. The third problem: The simplest, you can execute the mysqldump command.
- $database = "";//database name backed up
- $user = "";//database connection user name
- $password = "";//Database Password
- $outputfile = "";//The SQL file path of the exported backup
- System ($mysqldump. "-U". $user. "-P". $password. " ". $database." > ". $outputfile.");
- ?>
Copy Code------answer--------Your problems with the MySQL client software can be implemented, using MySQL cc or MySQL front can achieve your requirements, the use of the program will be very troublesome------answer--------to do it. or Google PHP MySQL class adobd lite------answer--------Good------answer--------for 1,3 can use the command line that comes with MySQL to complete the import and export work. Assume that the MySQL user name and password are root xxx, the database is test import SQL MYSQL-HLOCALHOST-UROOT-PXXX Test < XXX.SQL export SQL Mysqldump-hlocalhost-uroo T-pxxx Database > Xxx.sql for Excel, standard data can be converted to CVS-formatted data, and then imported with tools such as phpmyadmin------answer--------two ways: 1. Execute the mysql command directly, Let MySQL read the file 2. Read the file in PHP and execute the file contents. ------Solution--------1,3 is simple 2. Basically in the Chinese environment there is no perfect solution can use the DOM to write a small program to do the conversion------solution--------is com to =.=| | ------Answer--------The second question, you can write a CSV file to import the data can be imported into the MySQL database------solution--------Excel out of the kind of csv ... =_=| | The data is easy to use------answer--------support under 1. 2 Floor 2 question can consider MySQL ODBC------answer-------- Reference 7 Floor Froole reply: Two methods: 1. Execute the mysql command directly, let MySQL read the corresponding file 2. read the file in PHP and execute the file contents. Simple and concise expression------solution--------The above points are very high, sweat. ------Answer--------The second question is this, in order to batch import the database some files, before ASP is done by ASP to the. xls file read out, write into the database. Now to PHP, plus you are completely a novice, want to do is, the collation of the. xls file through PHP directly into the MySQL, is not so bad ah. What is the best way to achieve bulk import? For example, to import the names of all students in a school. ------Answer--------gingzai777 Master method is trying, is not the address behind the source must be an absolute address it? ------Answers-------- Reference 1 Floor gingzai777 's reply: 1, import the existing SQL file into the database, I write a function:
- $conn =mysql_connect ("localhost", "root", "password");//Specify Database connection parameters
- function Mysql_import ($file, $database)//Imported functions, parameters are SQL file path and imported library name.
- {
- mysql_select_db ($database);
- mysql_query ("source". $file. "';");
- echo "Import". $file. " File to ". $database." Database Complete ";
- }
- Mysql_close ($conn);
- ?>
Copy Code+---------Code---------------+
-
- function init_db () {
- $file = ": /install/import.sql ";
- $conn =mysql_connect ($this->dbhost, $this->dbuser, $this->dbpw) or Die ("Database connection Error");
- if (! $conn) {
- echo "Database connection error";
- }
- $db =mysql_select_db ($this->dbname);
- if ($db) {
- mysql_query ("DROP DATABASE". $this->dbname. " `");
- }
- mysql_query ("Setnames ' GBK '");
- $creatdb =mysql_query ("CREATE DATABASE". $this->dbname. " ' DEFAULT CHARACTER set gb2312 COLLATE gb2312_bin ');//Establish database
- $mysql =mysql_select_db ($this->dbname);
- //if ($mysql) {
- //echo "Connection";
- //}else{
- //echo "Not Connected";
- //}
- //echo $file;
- //$file = "source". $file. "'";
- //echo $file;
- mysql_query ("source". $file. ""); /Initialize Database
- mysql_close ($conn);
- }
-
Copy Code------Answer--------1, import the existing SQL file into the database, I write a function:
- $conn =mysql_connect ("localhost", "root", "password");//Specify Database connection parameters
- function Mysql_import ($file, $database)//Imported functions, parameters are SQL file path and imported library name.
- {
- mysql_select_db ($database);
- mysql_query ("source". $file. "';");
- echo "Import". $file. " File to ". $database." Database Complete ";
- }
- Mysql_close ($conn);
Copy Code |