|
Posted by NC on 05/10/06 03:19
apostolosl@gmail.com wrote:
>
> I need to update a remote database from a local one. I use mysqldump in
> my php page in order to create a file for each table, like this:
>
> $command="mysqldump table_products > table_products.sql";
> system($command);
>
> This works perfect and it gives me a file with a drop-table,
> create-table and all the insert values.
>
> Then I need to connect to the remote server and run the
> table_products.sql file.
>
> The way I do that is by calling the following in my php page:
>
> $command="mysql --host=$host --user=$user --password=$pass
> --database=$db;";
> system($command);
>
> , where $host, $user etc are being set at the top of the page. This
> works fine and I get connected to the remote database.
>
> Now I need to run the following mysql command: source stb_products.sql
You can run ONE command that would both connect you to the remote
server and execute the SQL file. Something like this:
$command = "mysql --host=$host --user=$user --password=$pass " .
"--database=$db < stb_products.sql";
system($command);
Cheers,
NC
Navigation:
[Reply to this message]
|