0

I exported .sql file local PC from localhost using

$sql = "SELECT * INTO OUTFILE '$backup_file' FIELDS TERMINATED BY ',' LINES TERMINATED BY ';' FROM $table_name";

After that I was uploaded this .sql file to remote server. Now I need to import this .sql file to same remote Mysql table with the name $table_name. I'm facing problem while using LOAD DATA INFILE command due to relative path issue from remote server to remote mysql server. Can anyone help me to create PHP script that import this .sql file which FIELDS TERMINATED BY ',' LINES TERMINATED BY ';' to Mysql table with the name $table_name?

1
  • Why not just import using phpMyAdmin or something? Commented Mar 26, 2013 at 12:53

1 Answer 1

1

Use "mysqldump" to export the database (http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html) and then use mysql syntax to import it on the other side with:

mysql -u <username> -p <database> < data.sql

Imports SQL database from "data.sql" into the database named "". "data.sql" is the files written by mysqldump command.

Alex

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.