# export a full SQL dump of your database

<div data-processed="true" data-subtree="aimfl,mfl" id="bkmrk-there-is-no-single-b" jscontroller="v48bt" jsuid="i0slrc_9" style="display: contents;">There is no single built-in</div>`php artisan` command to export a full SQL *dump* of your database and data. However, Laravel offers commands to manage your database structure via schema dumps or you can use third-party packages and external system commands for full data export.<span class="uJ19be notranslate" data-processed="true" data-wiz-uids="i0slrc_c,i0slrc_d,i0slrc_e"><span class="vKEkVd" data-animation-atomic="" data-processed="true" data-wiz-attrbind="class=i0slrc_c/TKHnVd;"> </span></span>

<div class="Y3BBE" data-hveid="CAEQAA" data-processed="true" data-sfc-cp="" id="bkmrk-" jsaction="rcuQ6b:&i0slrc_8|npT2md" jscontroller="zcfIf" jsuid="i0slrc_8">  
</div><div class="Fsg96" data-processed="true" data-sfc-cp="" id="bkmrk--1" jsaction="rcuQ6b:&i0slrc_f|npT2md" jscontroller="KHhJQ" jsuid="i0slrc_f">  
</div><div aria-level="3" class="otQkpb" data-animation-nesting="" data-processed="true" data-sfc-cp="" id="bkmrk-1.-exporting-databas" jscontroller="a7qCn" jsuid="i0slrc_g" role="heading">1. Exporting Database Schema (`schema:dump`)</div><div aria-level="3" class="otQkpb" data-animation-nesting="" data-processed="true" data-sfc-cp="" id="bkmrk--2" jscontroller="a7qCn" jsuid="i0slrc_g" role="heading">  
</div><div class="Y3BBE" data-hveid="CAMQAA" data-processed="true" data-sfc-cp="" id="bkmrk-laravel-provides-the" jsaction="rcuQ6b:&i0slrc_l|npT2md" jscontroller="zcfIf" jsuid="i0slrc_l">Laravel provides the `schema:dump` command to export the current database schema (table structures, not data) to an SQL file. This is primarily used to speed up migrations in large projects.<span class="uJ19be notranslate" data-processed="true" data-wiz-uids="i0slrc_n,i0slrc_o,i0slrc_p"><span class="vKEkVd" data-animation-atomic="" data-processed="true" data-wiz-attrbind="class=i0slrc_n/TKHnVd;"> </span></span></div><div class="Y3BBE" data-hveid="CAMQAA" data-processed="true" data-sfc-cp="" id="bkmrk--3" jsaction="rcuQ6b:&i0slrc_l|npT2md" jscontroller="zcfIf" jsuid="i0slrc_l">  
</div>- <span class="T286Pc" data-processed="true" data-sfc-cp="">**Dump the schema:**</span><div class="r1PmQe" data-hveid="CAQQAQ" data-processed="true" data-wiz-uids="i0slrc_x,i0slrc_y,i0slrc_z" jscontroller="HP6Sjf" jsuid="i0slrc_w"><div data-processed="true"><div class="pHpOfb" data-animation-atomic="" data-processed="true"><div class="vVRw1d" data-processed="true">bash</div></div></div></div>
- ```
    php artisan schema:dump
    
    ```
    
    <span class="T286Pc" data-processed="true" data-sfc-cp="">This command generates an `[connection-name]-schema.sql` file (e.g., `mysql-schema.sql`) in your `database/schema` directory. The file includes SQL commands equivalent to your migrations.</span>
- <span class="T286Pc" data-processed="true" data-sfc-cp="">**Dump schema and prune migrations:**</span><div class="r1PmQe" data-hveid="CAQQBA" data-processed="true" data-wiz-uids="i0slrc_1a,i0slrc_1b,i0slrc_1c" jscontroller="HP6Sjf" jsuid="i0slrc_19"><div data-processed="true"><div class="pHpOfb" data-animation-atomic="" data-processed="true"><div class="vVRw1d" data-processed="true">bash</div></div></div></div>

```
php artisan schema:dump --prune

```

<span class="T286Pc" data-processed="true" data-sfc-cp="">This command generates the SQL file and then deletes all your existing migration files, as they are no longer needed to build the initial schema.</span><span class="uJ19be notranslate" data-processed="true" data-wiz-uids="i0slrc_1g,i0slrc_1h,i0slrc_1i"><span class="vKEkVd" data-animation-atomic="" data-processed="true" data-wiz-attrbind="class=i0slrc_1g/TKHnVd;"> </span></span>

<div class="Fsg96" data-processed="true" data-sfc-cp="" id="bkmrk--4" jsaction="rcuQ6b:&i0slrc_1l|npT2md" jscontroller="KHhJQ" jsuid="i0slrc_1l">  
</div><div aria-level="3" class="otQkpb" data-animation-nesting="" data-processed="true" data-sfc-cp="" id="bkmrk-2.-exporting-full-da" jscontroller="a7qCn" jsuid="i0slrc_1m" role="heading">2. Exporting Full Database (Data + Schema)</div><div aria-level="3" class="otQkpb" data-animation-nesting="" data-processed="true" data-sfc-cp="" id="bkmrk--5" jscontroller="a7qCn" jsuid="i0slrc_1m" role="heading">  
</div><div class="Y3BBE" data-hveid="CAYQAA" data-processed="true" data-sfc-cp="" id="bkmrk-for-a-complete-datab" jsaction="rcuQ6b:&i0slrc_1q|npT2md" jscontroller="zcfIf" jsuid="i0slrc_1q">For a complete database backup including all data, the recommended approach is to use the `mysqldump` command directly or leverage a community package that wraps this functionality.<span class="uJ19be notranslate" data-processed="true" data-wiz-uids="i0slrc_1s,i0slrc_1t,i0slrc_1u"><span class="vKEkVd" data-animation-atomic="" data-processed="true" data-wiz-attrbind="class=i0slrc_1s/TKHnVd;"> </span></span></div><div class="Y3BBE" data-hveid="CAYQAA" data-processed="true" data-sfc-cp="" id="bkmrk--6" jsaction="rcuQ6b:&i0slrc_1q|npT2md" jscontroller="zcfIf" jsuid="i0slrc_1q">  
</div><div class="Fsg96" data-processed="true" data-sfc-cp="" id="bkmrk--7" jsaction="rcuQ6b:&i0slrc_1v|npT2md" jscontroller="KHhJQ" jsuid="i0slrc_1v">  
</div><div aria-level="3" class="AdPoic" data-animation-nesting="" data-processed="true" data-sfc-cp="" id="bkmrk-using-mysqldump-%28ext" jscontroller="SF2W9b" jsuid="i0slrc_1w" role="heading">Using `mysqldump` (External Command)<span class="uJ19be notranslate" data-processed="true" data-wiz-uids="i0slrc_1y,i0slrc_1z,i0slrc_20"><span class="vKEkVd" data-animation-atomic="" data-processed="true" data-wiz-attrbind="class=i0slrc_1y/TKHnVd;"> </span></span></div><div aria-level="3" class="AdPoic" data-animation-nesting="" data-processed="true" data-sfc-cp="" id="bkmrk--8" jscontroller="SF2W9b" jsuid="i0slrc_1w" role="heading">  
</div><div class="Y3BBE" data-hveid="CAgQAA" data-processed="true" data-sfc-cp="" id="bkmrk-you-can-run-system-l" jsaction="rcuQ6b:&i0slrc_21|npT2md" jscontroller="zcfIf" jsuid="i0slrc_21">You can run system-level commands from your terminal, which is the most reliable way to create a full SQL dump:</div><div class="Y3BBE" data-hveid="CAgQAA" data-processed="true" data-sfc-cp="" id="bkmrk--9" jsaction="rcuQ6b:&i0slrc_21|npT2md" jscontroller="zcfIf" jsuid="i0slrc_21">  
</div><div class="Fsg96" data-processed="true" data-sfc-cp="" id="bkmrk--10" jsaction="rcuQ6b:&i0slrc_25|npT2md" jscontroller="KHhJQ" jsuid="i0slrc_25">  
</div><div class="r1PmQe" data-hveid="CAkQAA" data-processed="true" data-wiz-uids="i0slrc_27,i0slrc_28,i0slrc_29" id="bkmrk-bash" jscontroller="HP6Sjf" jsuid="i0slrc_26"><div data-processed="true"><div class="pHpOfb" data-animation-atomic="" data-processed="true"><div class="vVRw1d" data-processed="true">bash</div></div></div></div>```
mysqldump -u [username] -p [database_name] > [filename].sql

```

- <span class="T286Pc" data-processed="true" data-sfc-cp="">Replace `[username]` with your MySQL username.</span>
- <span class="T286Pc" data-processed="true" data-sfc-cp="">`[database_name]` is the name of your database.</span>
- <span class="T286Pc" data-processed="true" data-sfc-cp="">`[filename].sql` is the desired output file name and path.</span>
- <span class="T286Pc" data-processed="true" data-sfc-cp="">You will be prompted to enter your database password after running the command.</span><span class="uJ19be notranslate" data-processed="true" data-wiz-uids="i0slrc_2o,i0slrc_2p,i0slrc_2q"><span class="vKEkVd" data-animation-atomic="" data-processed="true" data-wiz-attrbind="class=i0slrc_2o/TKHnVd;"> </span></span>

<div class="Fsg96" data-processed="true" data-sfc-cp="" id="bkmrk--11" jsaction="rcuQ6b:&i0slrc_2t|npT2md" jscontroller="KHhJQ" jsuid="i0slrc_2t">  
</div><div aria-level="3" class="AdPoic" data-animation-nesting="" data-processed="true" data-sfc-cp="" id="bkmrk-using-a-laravel-pack" jscontroller="SF2W9b" jsuid="i0slrc_2u" role="heading">Using a Laravel Package</div><div aria-level="3" class="AdPoic" data-animation-nesting="" data-processed="true" data-sfc-cp="" id="bkmrk--12" jscontroller="SF2W9b" jsuid="i0slrc_2u" role="heading">  
</div><div class="Y3BBE" data-hveid="CAwQAA" data-processed="true" data-sfc-cp="" id="bkmrk-for-an-integrated-so" jsaction="rcuQ6b:&i0slrc_2y|npT2md" jscontroller="zcfIf" jsuid="i0slrc_2y">For an integrated solution within your Laravel application, the popular `spatie/laravel-backup` package is widely recommended. It uses `mysqldump` internally and provides a simple Artisan command to run backups.<span class="uJ19be notranslate" data-processed="true" data-wiz-uids="i0slrc_31,i0slrc_32,i0slrc_33"><span class="vKEkVd" data-animation-atomic="" data-processed="true" data-wiz-attrbind="class=i0slrc_31/TKHnVd;"> </span></span></div><div class="Y3BBE" data-hveid="CAwQAA" data-processed="true" data-sfc-cp="" id="bkmrk--13" jsaction="rcuQ6b:&i0slrc_2y|npT2md" jscontroller="zcfIf" jsuid="i0slrc_2y">  
</div>1. <span class="T286Pc" data-processed="true" data-sfc-cp="">**Install the package:**</span><div class="r1PmQe" data-hveid="CA8QAQ" data-processed="true" data-wiz-uids="i0slrc_68,i0slrc_69,i0slrc_6a" jscontroller="HP6Sjf" jsuid="i0slrc_67"><div data-processed="true"><div class="pHpOfb" data-animation-atomic="" data-processed="true"><div class="vVRw1d" data-processed="true">bash</div></div></div></div>
2. ```
    composer require spatie/laravel-backup
    
    ```
3. <span class="T286Pc" data-processed="true" data-sfc-cp="">**Run the backup command:**</span><div class="r1PmQe" data-hveid="CA8QBA" data-processed="true" data-wiz-uids="i0slrc_6h,i0slrc_6i,i0slrc_6j" jscontroller="HP6Sjf" jsuid="i0slrc_6g"><div data-processed="true"><div class="pHpOfb" data-animation-atomic="" data-processed="true"><div class="vVRw1d" data-processed="true">bash</div></div></div></div>

```
php artisan backup:run

```

<span class="T286Pc" data-processed="true" data-sfc-cp="">This will create a compressed archive containing the SQL dump and save it in the `storage/app/backups` directory by default. You can find detailed instructions and configuration options on the official Spatie Laravel Backup documentation page</span>