{"id":259,"date":"2026-11-28T22:44:45","date_gmt":"2026-11-28T22:44:45","guid":{"rendered":"https:\/\/goadmio.com\/blog\/go-csv-command\/"},"modified":"2026-11-28T22:44:45","modified_gmt":"2026-11-28T22:44:45","slug":"go-csv-command","status":"publish","type":"post","link":"https:\/\/goadmio.com\/blog\/go-csv-command\/","title":{"rendered":"csv with the \/go\/csv Command"},"content":{"rendered":"<p>\/go\/csv runs a SELECT query on the server&#x27;s MariaDB\/MySQL database and saves the result as a CSV file. You can export a whole table, chosen columns, or a filtered result, from any database on the server. The query runs with the database root account, so it can read every database. Every admin action in <a href=\"https:\/\/www.goadmio.com\/\">GoAdmio<\/a> has a matching <code>\/go\/<\/code> command, so anything you can click you can also script.<\/p>\n<h2>Quick start<\/h2>\n<p><code># Export a whole table to \/root\/orders.csv<br \/>\n\/go\/csv -s &quot;SELECT * FROM shop.orders&quot; -o \/root\/orders.csv<br \/>\n<\/code><\/pre>\n<blockquote>\n<p>[!WARNING]<br \/>\nThe export file contains your data in plain text and can be large. Store it somewhere safe and delete it when you no longer need it. The query is also saved in <code>\/var\/log\/go\/csv.log<\/code>, so don&#8217;t put passwords or other secrets in it.<\/p>\n<\/blockquote>\n<h2>Options<\/h2>\n<table>\n<thead>\n<tr>\n<th>Option<\/th>\n<th>Required<\/th>\n<th>Notes<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>-s &lt;query&gt;<\/code><\/td>\n<td>Yes<\/td>\n<td>A single <code>SELECT<\/code> statement, without a trailing semicolon. Name the database in the query (<code>database.table<\/code>).<\/td>\n<\/tr>\n<tr>\n<td><code>-o &lt;file&gt;<\/code><\/td>\n<td>Yes<\/td>\n<td>The file to create. A relative path is relative to the current directory. An existing file is overwritten. Don&#8217;t use spaces in the name.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>If you pass an unknown option, the command prints <code>Usage: csv [-s] SQL Query [-o] Output File Name<\/code>, but it keeps going with the values it has. Always give both options.<\/p>\n<h2>Examples<\/h2>\n<p><code># Export rows that match a condition (single quotes inside the query)<br \/>\n\/go\/csv -s &quot;SELECT * FROM crm.DLD WHERE Mobile LIKE '20%' OR Keywords LIKE '%egypt%' GROUP BY Mobile&quot; -o egypt.csv<br \/>\n<\/code><\/pre>\n<p><code># Export two columns<br \/>\n\/go\/csv -s &quot;SELECT id, email FROM shop.users&quot; -o \/root\/users.csv<br \/>\n<\/code><\/pre>\n<p><code># Add a header row by putting it first with UNION ALL<br \/>\n\/go\/csv -s &quot;SELECT 'id','email' UNION ALL SELECT id, email FROM shop.users&quot; -o \/root\/users.csv<br \/>\n<\/code><\/pre>\n<p><code># Check the result<br \/>\nhead \/root\/users.csv<br \/>\nwc -l \/root\/users.csv<br \/>\n<\/code><\/pre>\n<h2>Output<\/h2>\n<p>The command prints nothing when it works. Errors from the database are shown on screen.<\/p>\n<p>Every run is logged with its arguments and a timestamp, for example <code>[Nov 20 09:15:02]# csv -s SELECT * FROM shop.orders -o \/root\/orders.csv<\/code>, to <code>\/var\/log\/go\/csv.log<\/code>.<\/p>\n<h3>File format<\/h3>\n<table>\n<thead>\n<tr>\n<th>Setting<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Separator<\/td>\n<td>Comma.<\/td>\n<\/tr>\n<tr>\n<td>Quoting<\/td>\n<td>Every value is wrapped in double quotes, numbers included.<\/td>\n<\/tr>\n<tr>\n<td>Line ending<\/td>\n<td>A new line (<code>\\n<\/code>).<\/td>\n<\/tr>\n<tr>\n<td>Header row<\/td>\n<td>None. The file contains only data rows.<\/td>\n<\/tr>\n<tr>\n<td>Special characters<\/td>\n<td>Escaped with a backslash. Quotes inside a value are written as <code>\\&quot;<\/code>, not doubled.<\/td>\n<\/tr>\n<tr>\n<td>Empty values<\/td>\n<td><code>NULL<\/code> is written as <code>\\N<\/code>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>See the full reference at <a href=\"https:\/\/www.goadmio.com\/commands\/csv\">\/go\/csv<\/a> and the <a href=\"https:\/\/www.goadmio.com\/commands\">GoAdmio command index<\/a>.<\/p>\n<p>GoAdmio is free and open source, with no license fees and no account limits. Read the <a href=\"https:\/\/www.goadmio.com\/docs\/\">GoAdmio docs<\/a>, or see why it is a <a href=\"https:\/\/www.goadmio.com\/cpanel-alternative.html\">free cPanel alternative<\/a> at <a href=\"https:\/\/www.goadmio.com\/\">goadmio.com<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/go\/csv runs a SELECT query on the server&#8217;s MariaDB\/MySQL database and saves the result as a CSV file. You can export a whole table, chosen columns, o&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-259","post","type-post","status-publish","format-standard","hentry","category-command-line"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>csv with the \/go\/csv Command - GoAdmio<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/goadmio.com\/blog\/go-csv-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"csv with the \/go\/csv Command - GoAdmio\" \/>\n<meta property=\"og:description\" content=\"\/go\/csv runs a SELECT query on the server&#039;s MariaDB\/MySQL database and saves the result as a CSV file. You can export a whole table, chosen columns, o...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/goadmio.com\/blog\/go-csv-command\/\" \/>\n<meta property=\"og:site_name\" content=\"GoAdmio\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-28T22:44:45+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/go-csv-command\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/go-csv-command\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/#\\\/schema\\\/person\\\/2792dfae1ff31de5831fd5c9ede251ce\"},\"headline\":\"csv with the \\\/go\\\/csv Command\",\"datePublished\":\"2026-11-28T22:44:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/go-csv-command\\\/\"},\"wordCount\":311,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/#organization\"},\"articleSection\":[\"Command Line\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/goadmio.com\\\/blog\\\/go-csv-command\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/go-csv-command\\\/\",\"url\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/go-csv-command\\\/\",\"name\":\"csv with the \\\/go\\\/csv Command - GoAdmio\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/#website\"},\"datePublished\":\"2026-11-28T22:44:45+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/go-csv-command\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/goadmio.com\\\/blog\\\/go-csv-command\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/go-csv-command\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"csv with the \\\/go\\\/csv Command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/\",\"name\":\"GoAdmio\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/#organization\",\"name\":\"GoAdmio\",\"url\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/goadmio-logo.png\",\"contentUrl\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/goadmio-logo.png\",\"width\":1200,\"height\":1200,\"caption\":\"GoAdmio\"},\"image\":{\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/#\\\/schema\\\/person\\\/2792dfae1ff31de5831fd5c9ede251ce\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d4bb3c53e2296776392ae05085feace43ad3be136196668f9d414210355127bd?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d4bb3c53e2296776392ae05085feace43ad3be136196668f9d414210355127bd?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d4bb3c53e2296776392ae05085feace43ad3be136196668f9d414210355127bd?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/goadmio.com\\\/blog\"],\"url\":\"https:\\\/\\\/goadmio.com\\\/blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"csv with the \/go\/csv Command - GoAdmio","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/goadmio.com\/blog\/go-csv-command\/","og_locale":"en_US","og_type":"article","og_title":"csv with the \/go\/csv Command - GoAdmio","og_description":"\/go\/csv runs a SELECT query on the server's MariaDB\/MySQL database and saves the result as a CSV file. You can export a whole table, chosen columns, o...","og_url":"https:\/\/goadmio.com\/blog\/go-csv-command\/","og_site_name":"GoAdmio","article_published_time":"2026-11-28T22:44:45+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/goadmio.com\/blog\/go-csv-command\/#article","isPartOf":{"@id":"https:\/\/goadmio.com\/blog\/go-csv-command\/"},"author":{"name":"admin","@id":"https:\/\/goadmio.com\/blog\/#\/schema\/person\/2792dfae1ff31de5831fd5c9ede251ce"},"headline":"csv with the \/go\/csv Command","datePublished":"2026-11-28T22:44:45+00:00","mainEntityOfPage":{"@id":"https:\/\/goadmio.com\/blog\/go-csv-command\/"},"wordCount":311,"commentCount":0,"publisher":{"@id":"https:\/\/goadmio.com\/blog\/#organization"},"articleSection":["Command Line"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/goadmio.com\/blog\/go-csv-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/goadmio.com\/blog\/go-csv-command\/","url":"https:\/\/goadmio.com\/blog\/go-csv-command\/","name":"csv with the \/go\/csv Command - GoAdmio","isPartOf":{"@id":"https:\/\/goadmio.com\/blog\/#website"},"datePublished":"2026-11-28T22:44:45+00:00","breadcrumb":{"@id":"https:\/\/goadmio.com\/blog\/go-csv-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/goadmio.com\/blog\/go-csv-command\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/goadmio.com\/blog\/go-csv-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/goadmio.com\/blog\/"},{"@type":"ListItem","position":2,"name":"csv with the \/go\/csv Command"}]},{"@type":"WebSite","@id":"https:\/\/goadmio.com\/blog\/#website","url":"https:\/\/goadmio.com\/blog\/","name":"GoAdmio","description":"","publisher":{"@id":"https:\/\/goadmio.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/goadmio.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/goadmio.com\/blog\/#organization","name":"GoAdmio","url":"https:\/\/goadmio.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/goadmio.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/goadmio.com\/blog\/wp-content\/uploads\/2026\/11\/goadmio-logo.png","contentUrl":"https:\/\/goadmio.com\/blog\/wp-content\/uploads\/2026\/11\/goadmio-logo.png","width":1200,"height":1200,"caption":"GoAdmio"},"image":{"@id":"https:\/\/goadmio.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/goadmio.com\/blog\/#\/schema\/person\/2792dfae1ff31de5831fd5c9ede251ce","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d4bb3c53e2296776392ae05085feace43ad3be136196668f9d414210355127bd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d4bb3c53e2296776392ae05085feace43ad3be136196668f9d414210355127bd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4bb3c53e2296776392ae05085feace43ad3be136196668f9d414210355127bd?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/goadmio.com\/blog"],"url":"https:\/\/goadmio.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/goadmio.com\/blog\/wp-json\/wp\/v2\/posts\/259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/goadmio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/goadmio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/goadmio.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/goadmio.com\/blog\/wp-json\/wp\/v2\/comments?post=259"}],"version-history":[{"count":0,"href":"https:\/\/goadmio.com\/blog\/wp-json\/wp\/v2\/posts\/259\/revisions"}],"wp:attachment":[{"href":"https:\/\/goadmio.com\/blog\/wp-json\/wp\/v2\/media?parent=259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/goadmio.com\/blog\/wp-json\/wp\/v2\/categories?post=259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/goadmio.com\/blog\/wp-json\/wp\/v2\/tags?post=259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}