Home > Database > Mysql Tutorial > Can you export data to a client host file using `SELECT * INTO OUTFILE` in MySQL?

Can you export data to a client host file using `SELECT * INTO OUTFILE` in MySQL?

DDD
Release: 2024-10-25 20:29:28
Original
397 people have browsed it

Can you export data to a client host file using `SELECT * INTO OUTFILE` in MySQL?

SELECT * INTO OUTFILE LOCAL in MySQL

MySQL's SELECT * INTO OUTFILE statement allows users to export data from a table to a text file on the server machine. However, if the desired location of the file is on a client host different from the server, the statement is hindered by security concerns.

This limitation does not apply to the LOAD DATA INFILE statement. By adding LOCAL before INFILE, users can load data from a file located on the client host.

Unfortunately, there is no equivalent SELECT INTO OUTFILE LOCAL statement in MySQL. The manual explains that the INTO OUTFILE statement is primarily intended for creating text file dumps on the server machine. For client host destinations, it recommends using the mysql command with the -e option.

mysql -h my.db.com -u usrname --password=pass db_name -e 'SELECT foo FROM bar' > /tmp/myfile.txt

MariaDB's Handling of this Problem

Whether MariaDB can handle this problem is unknown as it was not mentioned in the question or answer provided.

The above is the detailed content of Can you export data to a client host file using `SELECT * INTO OUTFILE` in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template