<p><strong>Vers un fichier texte/CSV depuis la ligne de commande :</strong></p>
<pre data-code-wrap="bash"><code class="lang-bash">mysql -u user -p -e "SELECT * FROM table" database > resultats.txt
</code></pre>
<p><strong>Vers un fichier CSV :</strong></p>
<pre data-code-wrap="sql"><code class="lang-sql">SELECT * FROM table
INTO OUTFILE '/tmp/resultats.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
</code></pre>
<p><strong>Depuis MySQL Workbench :</strong><br>
Exécutez la requête, puis clic droit sur le résultat > Export Result Set > sélectionnez le format (CSV, Excel, etc.)</p>