snipt

Ctrl+h for KB shortcuts

MySQL

Import Excel CSV into mysql table

1
2
3
4
5
LOAD DATA LOCAL INFILE 'file.cvs' INTO TABLE tablename
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
(field1, field2, field3)
https://snipt.net/embed/b45c79fed7778c5162ab2733e55610f7/
/raw/b45c79fed7778c5162ab2733e55610f7/
b45c79fed7778c5162ab2733e55610f7
mysql
MySQL
6
2019-06-25T18:24:32
True
False
False
/api/public/snipt/4923/
import-excel-csv-into-mysql-table
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">LOAD</span> <span class="n">DATA</span> <span class="n">LOCAL</span> <span class="k">INFILE</span> <span class="s1">&#39;file.cvs&#39;</span> <span class="k">INTO</span> <span class="k">TABLE</span> <span class="n">tablename</span> </span><span id="L-2"><a name="L-2"></a><span class="n">FIELDS</span> <span class="k">TERMINATED</span> <span class="k">BY</span> <span class="s1">&#39;,&#39;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">ENCLOSED</span> <span class="k">BY</span> <span class="s1">&#39;&quot;&#39;</span> </span><span id="L-4"><a name="L-4"></a><span class="k">LINES</span> <span class="k">TERMINATED</span> <span class="k">BY</span> <span class="s1">&#39;\r\n&#39;</span> </span><span id="L-5"><a name="L-5"></a><span class="p">(</span><span class="n">field1</span><span class="p">,</span> <span class="n">field2</span><span class="p">,</span> <span class="n">field3</span><span class="p">)</span> </span></pre></div> </td></tr></table>
csv, excel, mysql

Bash

Find the location of the currently used binary on unix

$ which mysql
/usr/bin/mysql
https://snipt.net/embed/5b390f07c5e451699a43dc6d8dfd95e2/
/raw/5b390f07c5e451699a43dc6d8dfd95e2/
5b390f07c5e451699a43dc6d8dfd95e2
bash
Bash
2
2019-06-21T17:47:39
True
False
False
/api/public/snipt/4532/
find-the-location-of-the-currently-used-binary-on-unix
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ which mysql </span><span id="L-2"><a name="L-2"></a>/usr/bin/mysql </span></pre></div> </td></tr></table>
bash, which

Bash

Reset a file's contents to ''

echo -n "" > /path/to/file
https://snipt.net/embed/c856c1428a8d8f8b591840636d6b88ff/
/raw/c856c1428a8d8f8b591840636d6b88ff/
c856c1428a8d8f8b591840636d6b88ff
bash
Bash
1
2019-05-29T05:33:08
True
False
False
/api/public/snipt/3455/
reset-a-files-contents-to
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nb">echo</span> -n <span class="s2">&quot;&quot;</span> &gt; /path/to/file </span></pre></div> </td></tr></table>
bash