Migrating databases can present unexpected challenges, as some features may no longer function as expected. In the case of MySQL, the SELECT * INTO OUTFILE statement, once used to export data to a text file, no longer works due to security reasons.
However, the LOAD DATA INFILE statement can be modified to LOAD DATA LOCAL INFILE, allowing data to be imported from a local file. This begs the question: why is there no equivalent SELECT INTO OUTFILE LOCAL?
According to the MySQL manual, SELECT * INTO OUTFILE is primarily intended for quickly generating text files on the server. However, creating files on remote clients is not permitted due to security concerns.
As an alternative, the following command can be used to generate files on the client host:
mysql -h my.db.com -u username -p password db_name -e'SELECT foo FROM bar' > /tmp/myfile.txt
Regarding MariaDB, it does not appear to offer a direct solution to this issue. However, it provides additional security features for data transfer, such as the ability to restrict file access to specific users or IP addresses.
The above is the detailed content of Why Doesn\'t MySQL Offer a \'SELECT * INTO OUTFILE LOCAL\' Equivalent?. For more information, please follow other related articles on the PHP Chinese website!