snipt

Ctrl+h for KB shortcuts

SQL

Dump a list of tables from a database

mysqldump -u <user> -p <database> <table1> <table2> .... > dump.sql
https://snipt.net/embed/10c28b8700ab554d742a298429ab98f9/
https://snipt.net/raw/10c28b8700ab554d742a298429ab98f9/
10c28b8700ab554d742a298429ab98f9
sql
SQL
1
2016-09-23T22:06:30
True
False
True
Feb 15, 2013 at 03:59 PM
/api/public/snipt/55835/
dump-a-list-of-tables-from-a-database
<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 id="L-1"><a name="L-1"></a><span class="n">mysqldump</span> <span class="o">-</span><span class="n">u</span> <span class="o">&lt;</span><span class="k">user</span><span class="o">&gt;</span> <span class="o">-</span><span class="n">p</span> <span class="o">&lt;</span><span class="k">database</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">table1</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">table2</span><span class="o">&gt;</span> <span class="p">....</span> <span class="o">&gt;</span> <span class="n">dump</span><span class="p">.</span><span class="k">sql</span> </span></pre></div> </td></tr></table>
mysqldump, sql

SQL

mysqldump only schema

mysqldump -d -u <user> -p <database> > dumpfile.sql
https://snipt.net/embed/fdba77f9ac5bc421e3dfb54695396495/
https://snipt.net/raw/fdba77f9ac5bc421e3dfb54695396495/
fdba77f9ac5bc421e3dfb54695396495
sql
SQL
1
2016-09-18T05:33:53
True
False
False
Aug 22, 2012 at 03:07 PM
/api/public/snipt/46126/
mysqldump-only-schema
<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 id="L-1"><a name="L-1"></a><span class="n">mysqldump</span> <span class="o">-</span><span class="n">d</span> <span class="o">-</span><span class="n">u</span> <span class="o">&lt;</span><span class="k">user</span><span class="o">&gt;</span> <span class="o">-</span><span class="n">p</span> <span class="o">&lt;</span><span class="k">database</span><span class="o">&gt;</span> <span class="o">&gt;</span> <span class="n">dumpfile</span><span class="p">.</span><span class="k">sql</span> </span></pre></div> </td></tr></table>
mysqldump

Text only

Mysql dump using SSH

mysqldump --opt -u [dbuser] -p [dbname]> [filename].sql
https://snipt.net/embed/93535cce40c45c2f80c726e5c078f6a7/
https://snipt.net/raw/93535cce40c45c2f80c726e5c078f6a7/
93535cce40c45c2f80c726e5c078f6a7
text
Text only
1
2016-09-22T03:03:29
True
False
False
Jan 15, 2014 at 08:56 PM
/api/public/snipt/43134/
mysql-dump-using-ssh
<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 id="L-1"><a name="L-1"></a>mysqldump --opt -u [dbuser] -p [dbname]&gt; [filename].sql </span></pre></div> </td></tr></table>
cmd, command-line, console, linux, mysql, mysqldump, server, ssh

Bash

database backup on Plesk VPS

1
2
3
mysqldump --add-drop-table -u admin -p`cat /etc/psa/.psa.shadow` dbanme > dbname.sql

mysqldump -u admin -p`cat /etc/psa/.psa.shadow ` dbname > dump.sql
https://snipt.net/embed/67798b161cfe28059095f7934df6902e/
https://snipt.net/raw/67798b161cfe28059095f7934df6902e/
67798b161cfe28059095f7934df6902e
bash
Bash
3
2016-09-26T06:51:58
True
False
False
Dec 11, 2012 at 02:59 PM
/api/public/snipt/36952/
database-backup
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>mysqldump --add-drop-table -u admin -p<span class="sb">`</span>cat /etc/psa/.psa.shadow<span class="sb">`</span> dbanme &gt; dbname.sql </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>mysqldump -u admin -p<span class="sb">`</span>cat /etc/psa/.psa.shadow <span class="sb">`</span> dbname &gt; dump.sql </span></pre></div> </td></tr></table>
backup, database, mysql, mysqldump

Bash

backup mysql

1
2
3
4
5
#hacer copia de seguridad de base de datos en mysql
mysqldump --opt --password=miclave --user=miuser mibasededatos > archivo.sql

#resturar la copia de seguridad
mysql --password=miclave --user=miuser mibase < archivo.sql
https://snipt.net/embed/00751c547d341c6d8f47bfc5b21d68d2/
https://snipt.net/raw/00751c547d341c6d8f47bfc5b21d68d2/
00751c547d341c6d8f47bfc5b21d68d2
bash
Bash
5
2016-09-26T05:17:07
True
False
False
/api/public/snipt/27942/
backup-mysql
<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 id="L-1"><a name="L-1"></a><span class="c">#hacer copia de seguridad de base de datos en mysql</span> </span><span id="L-2"><a name="L-2"></a>mysqldump --opt --password<span class="o">=</span>miclave --user<span class="o">=</span>miuser mibasededatos &gt; archivo.sql </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c">#resturar la copia de seguridad</span> </span><span id="L-5"><a name="L-5"></a>mysql --password<span class="o">=</span>miclave --user<span class="o">=</span>miuser mibase &lt; archivo.sql </span></pre></div> </td></tr></table>
backup, dump, mysql, mysqldump, restore

Text only

mysqldump

$ mysqldump -u [username] -p [password] --databases [databasename] > [file_path]
https://snipt.net/embed/2e4fef4cb9a8b576332f536f69552f96/
https://snipt.net/raw/2e4fef4cb9a8b576332f536f69552f96/
2e4fef4cb9a8b576332f536f69552f96
text
Text only
2
2016-09-14T08:13:11
True
False
False
/api/public/snipt/22186/
mysqldump-2
<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 id="L-1"><a name="L-1"></a>$ mysqldump -u [username] -p [password] --databases [databasename] &gt; [file_path] </span></pre></div> </td></tr></table>
mysqldump

Bash

Database dump and import from the commandline

1
2
3
4
5
#dump
mysqldump db_name --user=db_user -p > backup.sql

#import
mysql --user=username -p db_name < backup.sql
https://snipt.net/embed/55ee90c093ef42f638112fe20e7af750/
https://snipt.net/raw/55ee90c093ef42f638112fe20e7af750/
55ee90c093ef42f638112fe20e7af750
bash
Bash
5
2016-09-21T00:41:15
True
False
False
/api/public/snipt/12915/
dump-a-database-from-the-commandline
<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 id="L-1"><a name="L-1"></a><span class="c">#dump</span> </span><span id="L-2"><a name="L-2"></a>mysqldump db_name --user<span class="o">=</span>db_user -p &gt; backup.sql </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c">#import</span> </span><span id="L-5"><a name="L-5"></a>mysql --user<span class="o">=</span>username -p db_name &lt; backup.sql </span></pre></div> </td></tr></table>
backup, dump, mysql, mysqldump

Bash

mysqldump

$ mysqldump -u [username] -p [password] --databases [databasename] > [file_path]
https://snipt.net/embed/aed7d2073f4869bba3ca46a3bbd1944f/
https://snipt.net/raw/aed7d2073f4869bba3ca46a3bbd1944f/
aed7d2073f4869bba3ca46a3bbd1944f
bash
Bash
1
2016-09-26T03:03:55
True
False
False
/api/public/snipt/11760/
mysqldump-1
<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 id="L-1"><a name="L-1"></a><span class="nv">$ </span>mysqldump -u <span class="o">[</span>username<span class="o">]</span> -p <span class="o">[</span>password<span class="o">]</span> --databases <span class="o">[</span>databasename<span class="o">]</span> &gt; <span class="o">[</span>file_path<span class="o">]</span> </span></pre></div> </td></tr></table>
mysql, mysqldump

Bash

clean mysqldump

mysqldump --disable-extended-insert --add-drop-table -u admin -p`cat /etc/psa/.psa.shadow` dbname tablename > file.sql
https://snipt.net/embed/de52625411e33ab3bf0fc6ed43e2464a/
https://snipt.net/raw/de52625411e33ab3bf0fc6ed43e2464a/
de52625411e33ab3bf0fc6ed43e2464a
bash
Bash
1
2016-09-21T10:10:59
True
False
False
/api/public/snipt/9985/
clean-mysqldump
<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 id="L-1"><a name="L-1"></a>mysqldump --disable-extended-insert --add-drop-table -u admin -p<span class="sb">`</span>cat /etc/psa/.psa.shadow<span class="sb">`</span> dbname tablename &gt; file.sql </span></pre></div> </td></tr></table>
clean, dump, mysql, mysqldump

MySQL

backup a database using date as name file

mysqldump -u <user> -p<pass> <mysite> -r <mysite>-$(date +%d.%b.%Y).sql
https://snipt.net/embed/121c028f636f17324d62bb3d399ea8c1/
https://snipt.net/raw/121c028f636f17324d62bb3d399ea8c1/
121c028f636f17324d62bb3d399ea8c1
mysql
MySQL
1
2016-09-26T07:06:13
True
False
False
/api/public/snipt/9688/
backup-a-database-using-date-as-name-file
<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 id="L-1"><a name="L-1"></a><span class="n">mysqldump</span> <span class="o">-</span><span class="n">u</span> <span class="o">&lt;</span><span class="n">user</span><span class="o">&gt;</span> <span class="o">-</span><span class="n">p</span><span class="o">&lt;</span><span class="n">pass</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">mysite</span><span class="o">&gt;</span> <span class="o">-</span><span class="n">r</span> <span class="o">&lt;</span><span class="n">mysite</span><span class="o">&gt;-</span><span class="err">$</span><span class="p">(</span><span class="kt">date</span> <span class="o">+%</span><span class="n">d</span><span class="p">.</span><span class="o">%</span><span class="n">b</span><span class="p">.</span><span class="o">%</span><span class="n">Y</span><span class="p">).</span><span class="k">sql</span> </span></pre></div> </td></tr></table>
backup, mysql, mysqldump
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.