0

Question is similar to MySQL dump by query but with the difference that the SELECT query I want is super long (almost 1000 lines)

So just to put it in perspective,

mysql -e "SELECT * from myTable WHERE id NOT IN (*lots of specific id numbers*)" -u myuser -pxxxxxxxxx mydatabase > output.txt

How can I achieve this?

I also tried going into the DB itself and running the query there and adding INTO OUTFILE '/tmp/querydump.csv' in the end but get the error;

ERROR 1045 (28000): Access denied for user 'admin'@'%' (using password: YES)

Any helpful tips please? Thanks in advance.

  • Tip: always read the [documentation](https://dev.mysql.com/doc/refman/8.0/en/select-into.html): "*The file is created on the server host, so you must have the `FILE` privilege to use this syntax.*" – Bill Karwin Jul 06 '22 at 14:25

1 Answers1

0

Since I couldn't manage to do this from server side due to the long query output, found a workaround by using MySQL Workbench which is a very helpful tool to use in such casesenter image description here