How to import a database?
Requirements:
- backup copy dump: BackupSqlManager , or software documentation if the base was created locally,
- access code to the database, sent in the email when hosting service activation.
It may be necessary to add the following line on the top of your backup copy:
use name_of_database;
database = the name in which you will import the data
Through the script
You can now edit the script. Substitute:
- name_of_the_base.sql with the file name,
- server_sql with server on which database is installed,
- name_of_the_base with the database name,
- password with password assigned to the database.
- In PHP (importbase.php) :
echo "Your base restoration is in progress.......
";
system("cat name_of_the_base.sql | mysql --host=server_sql --user=name_of_the_base --password=password name_of_the_base");
echo "End.Your base is on your hosting.";
?>
- In PERL (importbase.cgi) :
#!/usr/bin/perl
print "Your base restoration is in progress.......
";
system("cat name_of_the_base.sql | mysql --host=server_sql --user=name_of_the_base --password=password name_of_the_base");
print "End.Your base is on your hosting.";
Upload the script you have created as well as the dump to www directory. The script should be accessible from the link:
http://yourdomain.com/script_path/importbase.php
Note: If your dump is in .sql.gz, you need only to place this command at the beginning of the script:
system("gunzip base_name.sql.gz");
Example :
In PHP :
echo "unzip file.....
";
system("gunzip testbackup.sql.gz");
echo "Your base restoration is in progress......
";
system("cat testbackup.sql | mysql --host=sql3 --user=testimport --password=RtPgDsmL testimport");
echo "End.Your base is on your hosting.";
?>
In PERL:
#!/usr/bin/perl
print "Unzip file.....
";
system("gunzip testbackup.sql.gz");
print "Your base restoration is in progress.......
";
system("cat testbackup.sql | mysql --host=sql3 --user=testimport --password=RtPgDsmL testimport");
print "End.Your base is on your hosting.";
Through command lines
If you have one Plan service, you may copy your base via ssh. It's sufficient to connect to your ssh server, choose a directory and enter the following command:
cat name_of_the_base.sql | mysql --host=server_sql --
user=name_of_the_base --password=password name_of_the_base
Example :
cat testbackup.sql | mysql --host=sql3 --user=testimport --password=RtPgDsmL testimport
Via phpMyAdmin
etc.