0

In an attempt to export data from MySQL to a .csv file, I execute the following:

SELECT 'BAT_POSITION_IN_SERIES', 'NUMBER_OF_PITCHES', 'PCT_BALLS', 'PCT_CALLED_STRIKE', 'STRIKEOUTS_PER_PITCH', 'WALKS_PER_PITCH', 'HITS_PER_PITCH', 'RUNS_PER_PITCH' 
UNION 
SELECT * 
FROM per_pitch_summary 
INTO OUTFILE 'C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\per_pitch_summary.csv' 
FIELDS ENCLOSED BY '"' 
TERMINATED BY ',' 
ESCAPED BY '"' 
LINES TERMINATED BY '\n' ;

however I am unable to see the Uploads folder as indicated in the file path. It must exist, because when I re-execute the query, I receive an error message indicating the .csv file already exists. Any suggestions? Why would I not be able to see the folder?

CraigS
  • 37
  • 1
  • 7
  • *however I am unable to see the Uploads folder as indicated in the file path.* Does this foldex exists before you execute this query firstly? Does it is accessible by OS account which is used for `mysql` service? Try to find this folder and file via CMD executed from system account (use psexec). – Akina Feb 02 '21 at 13:09
  • I am not certain how this behaves on Windows when specifying the full path, but on Unix the outfile will end up in the data directory of the database you are working with without the full path. There are some Windows anecdotes [over here](https://stackoverflow.com/questions/11484471/cant-find-the-file-created-by-outfile-in-mysql/11484527#11484527) – Michael Berkowski Feb 02 '21 at 13:16
  • One thing I notice from the linked examples is some Windows users are using double backslashes (which makes sense when I think about it ) `C:\\ProgramData\\...` or use single forward slashes `C:/ProgramData/` This might be your issue, and you might find a very weirdly named csv inside the database's data directory – Michael Berkowski Feb 02 '21 at 13:19
  • Thanks for the replies... @Akina: I have tried both with and without creating the folder manually. And yes, the folder is available via command prompt window, but not visible using the File Explorer. That said, I can see the bin, include, lib and share folders using File Explorer. – CraigS Feb 02 '21 at 13:23
  • *the folder is available via command prompt window, but not visible using the File Explorer.* Adjust directory attributes, add needed access permissions to your OS account (maybe, make Administrators group the owner of this folder previously). – Akina Feb 02 '21 at 13:26
  • Thanks, @MichaelBerkowski. I have played around with the forward/back slashes as well. No dice. – CraigS Feb 02 '21 at 13:27
  • I have a related question posted here:https://stackoverflow.com/questions/65994028/change-default-outfile-location-to-avoid-error-code-1290-my-ini-not-available, if some related information might be helpful. – CraigS Feb 02 '21 at 13:28
  • Solved! Thanks, @Akina – CraigS Feb 02 '21 at 20:09

0 Answers0