I would like to upload a sql-dump from mariadb to a remote server with php (curl?).
I have tried the following:
<?php
$file_name_with_full_path = '/path/file.sql';
if (function_exists('curl_file_create')) { // php 5.5+
$cFile = curl_file_create($file_name_with_full_path);
} else { //
$cFile = '@' . realpath($file_name_with_full_path);
}
$target_url = "server";
$post = array('extra_info' => '123456','file_contents'=> $cFile);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result=curl_exec ($ch);
curl_close ($ch);
as an answer I get something like:
versionInfo-MariaDBrddas2_fafdas_Mmysql_native_password! #08S01Got packets out of order
does anyone know hot to fix that? I think i might be close...
According to the error message you seem to connect via curl directly to the MariaDB server.
Curl doesn't support the MariaDB/MySQL protocol, and the MariaDB server doesn't provide an interface for obtaining (remote) sql-dumps.
What you have to do is:
If you want to do that automatically, you will need a script or cron job on the server, which frequently checks the directory, which contains uploaded dump files.
Thanks for the replies. As it's not feasible to deploy ftps, i copy the tables one by one with a cronjob (php/mariadb), as the mariadb communicatin works between the servers, but unfortunatly not to the point where we can use db replication...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.