Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General »

[SOLUCIONADO] Guardar en local consulta remota

Estas en el tema de Guardar en local consulta remota en el foro de Bases de Datos General en Foros del Web. Hola compañeros, llevo tiempo aclarando mis dudas en este foro pero con este problema no he encontrado ninguna solucion. Al grano, resulta tengo 2 maquinas ...
  #1 (permalink)  
Antiguo 27/03/2016, 10:01
 
Fecha de Ingreso: marzo-2016
Ubicación: Barcelona
Mensajes: 2
Antigüedad: 8 años, 1 mes
Puntos: 0
Guardar en local consulta remota

Hola compañeros, llevo tiempo aclarando mis dudas en este foro pero con este problema no he encontrado ninguna solucion.

Al grano, resulta tengo 2 maquinas virtuales, una se conecta remotamente a la bbdd de la otra, hasta aqui todo perfecto, pero resulta que necesito pasar el resultado de una consulta a texto plano y gurdarla en el cliente que conecta remotamente, pero resulta que al activarse el evento que he creado, lo guarda en la ruta indicada pero del servidor, entonces la pregunta es ¿ Hay manera de que quede guardada en el cliente?

Código SQL:
Ver original
  1. CREATE event copia ON schedule every DAY starts 'xxxx.xx.xx xx:xx:xx'
  2.  do SELECT pais,nombre INTO OUTFILE '/datos.txt' FROM emple,depart ...

esto es parte del codigo para que os podais hacer una idea, el evento funciona sin problema, pero lo guarda en el server de la bbdd.

Espero haberme explicado medianamente. Gracias por adelantado.

Un saludo

Última edición por gnzsoloyo; 27/03/2016 a las 10:08 Razón: Codigo sin etiquetar.
  #2 (permalink)  
Antiguo 27/03/2016, 10:13
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: Guardar en local consulta remota

Bueno, asumiendo que el DBMS es MySQL, siempre puedes recurrir al manual de referencia:
Cita:
The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected rows to a file. The file is created on the server host, so you must have the FILE privilege to use this syntax. file_name cannot be an existing file, which among other things prevents files such as /etc/passwd and database tables from being destroyed. The character_set_filesystem system variable controls the interpretation of the file name.

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.

However, if the MySQL client software is installed on the remote machine, you can instead use a client command such as mysql -e "SELECT ..." > file_name to generate the file on the client host.

It is also possible to create the resulting file on a different host other than the server host, if the location of the file on the remote host can be accessed using a network-mapped path on the server's file system. In this case, the presence of mysql (or some other MySQL client program) is not required on the target host.
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #3 (permalink)  
Antiguo 27/03/2016, 12:41
 
Fecha de Ingreso: marzo-2016
Ubicación: Barcelona
Mensajes: 2
Antigüedad: 8 años, 1 mes
Puntos: 0
Respuesta: Guardar en local consulta remota

Hola compañero, en efecto, se trata de mysql y ya tengo el tema solucionado con

Código:
mysql -u usuario -h ip -p -e "sentencia select" > nombre_archivo
muchas gracias por la rapida y certera respuesta, la verdad he estado mirando la docu oficial pero eso se me ha pasado.

Saludos

Etiquetas: mysql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:44.