snipt

Ctrl+h for KB shortcuts

Bash

Restore and Import MySQL dump

mysql -u username -ppassword database_name < dump.sql
https://snipt.net/embed/db660354aadf4edae6b81839c8a29ff4/
/raw/db660354aadf4edae6b81839c8a29ff4/
db660354aadf4edae6b81839c8a29ff4
bash
Bash
1
2019-06-17T04:32:46
True
False
False
/api/public/snipt/6904/
restore-and-import-mysql-dump
<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>mysql -u username -ppassword database_name &lt; dump.sql </span></pre></div> </td></tr></table>
archive, backup, mysql, shell

Bash

Backup ALL MySQL DBs

mysqldump -u username -ppassword –all-databases > dump.sql
https://snipt.net/embed/a427e3c7f3e7597add52df495bb61454/
/raw/a427e3c7f3e7597add52df495bb61454/
a427e3c7f3e7597add52df495bb61454
bash
Bash
1
2019-06-15T05:52:15
True
False
False
/api/public/snipt/6903/
backup-all-mysql-dbs
<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>mysqldump -u username -ppassword –all-databases &gt; dump.sql </span></pre></div> </td></tr></table>
archive, backup, mysql, shell

Bash

Backup and compress a MySQL DB

mysqldump $DB_NAME -R -q --user=$USER --password=$PASSWORD --lock-tables | gzip > $BACKUPDIR/$BACKUPNAME
https://snipt.net/embed/ded50795e42c5309713131ffdceee243/
/raw/ded50795e42c5309713131ffdceee243/
ded50795e42c5309713131ffdceee243
bash
Bash
2
2019-06-15T10:16:24
True
False
False
/api/public/snipt/6900/
backup-and-compress-a-mysql-db
<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>mysqldump <span class="nv">$DB_NAME</span> -R -q --user<span class="o">=</span><span class="nv">$USER</span> --password<span class="o">=</span><span class="nv">$PASSWORD</span> --lock-tables <span class="p">|</span> gzip &gt; <span class="nv">$BACKUPDIR</span>/<span class="nv">$BACKUPNAME</span> </span></pre></div> </td></tr></table>
archive, backup, mysql, shell