Question

I know that's it's possible to do a remote mysqldump if I specify --host but is it possible to create the file in the remote server as well?

Was it helpful?

Solution 4

It's not possible to do the mysqldump directly to a remote location (like in other sgdb's).

OTHER TIPS

@aF I thought that the solution mentioned by @tersmitten was a Unix NAMED FIFO PIPE - so you actually store a minimum of data on your system. Take a look at the mknod/mkfifo named pipes here. Try a few of the links from Googling this (intermachine IPC mkfifo example). I vaguely remember doing this for Oracle redo logs years ago.

A couple of thoughts - maybe you could mount a network drive from the other machine on your server and pipe your backup to that? Or the cloud - how big is it? Dropbox and other services offer this - Google drive?

[EDIT] (Pity I'm on the laptop today - no access to a machine to check out my theories about this fascinating question (gave you +1).

Take a look here - some results which jumped out at me were these (1, 2, 3 & 4).

[EDIT2] (My brain is really not working today! :-) )

Why not replicate to the remote machine and then backup the replica? Quick and easy replication is _THE_ reason why MySQL won the F\LOSS database wars. Backup (at quiet times) allow the replica to fall behind at these quiet times quiet times and then catching back up won't be a problem. What storage engine are you using - MyISAM or InnoDB? What version of MySQL?

You are better off just getting the necessary root access to ssh straight in and scp the file or dump.

If you cannot ssh into the server with root access but you simply interested in dumping the file inside the local DB Server, you have very limited options. In fact, I can only think of one option.

The only way to mysqldump data locally is not to use mysqldump itself but duplicate what mysqldump can do. Since mysqldump is capable of creating CSV files but you do not have OS access, you need to take matters into your own hands.

Login to mysql and run SELECT ... INTO OUTFILE .

Here is a sample for the MySQL Documentation on SELECT ... INTO OUTFILE

SELECT a,b,a+b INTO OUTFILE '/tmp/result.txt'
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
  LINES TERMINATED BY '\n'
  FROM test_table;

This requires secure_file_priv be set to a specific folder. You also need the FILE privilege.

To fully clarify the aforementioned query, keep in mind that the target system of SELECT ... INTO OUTFILE is the DB Server, not the client side. It says so in the MySQL Documentation:

The SELECT ... INTO OUTFILE statement is intended primarily to let you very quickly dump a table to a text file on the server machine. If you want to create the resulting file on some other host than the server host, you normally cannot use SELECT ... INTO OUTFILE since there is no way to write a path to the file relative to the server host's file system.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top