Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8654599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:49:41+00:00 2026-06-12T14:49:41+00:00

I have written a script to do regular exports of my database : #!/bin/bash

  • 0

I have written a script to do regular exports of my database :

#!/bin/bash

current_date=`date '+%F-%H-%M-%S'`

cd /home/user/Documents/backup
mysqldump -umyusername -pmypassword mydb > db-backup-$current_date.sql
tar czvf db-backup-$current_date.tgz db-backup-$current_date.sql
rm db-backup-$current_date.sql

but I would like to export it with the following options available with phpMyAdmin :

  • Enclose export in a transaction
  • Disable foreign key checks
  • Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT statement

How I can do that ?

EDIT

I can add the following lines at the beginning of mydatabase.sql file ?

SET FOREIGN_KEY_CHECKS=0;
SET AUTOCOMMIT=0;
START TRANSACTION;

If it is right to do that, so I guess my problem is how to insert lines in a given position ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:49:43+00:00Added an answer on June 12, 2026 at 2:49 pm

    Yo can probably do most of it through mysqldump itself:

    mysqldump \
    --user=LOGIN \
    --password=PASSWORD \
    --single-transaction \
    --events \
    --triggers \
    --routines \
    --disable-keys \
    --create-options \
    database  > dumpfile.sql
    

    The --create-options should issue the drop command too.

    Have a look at mysqldump --help for a list of all possible options

    An alternative is to look in the PHP for phpMyAdmin and see what options it uses

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written simple script: #!/bin/bash find . -name *.m4a | while read filename;
I have written a bash script which installs a number of packages, however for
I have written a script that will keep itself up to date by downloading
Basically I have written a script to allow the user in the back end
Possible Duplicate: PHP - send file to user I have written a script that
I have written php script for user login but instead of displaying the result
I have written a script in haskell named testscript with the following code: #!/usr/bin/env
I have written a script to query a mysql database and encode the data
I have written a script which is fetching data from database. Now I want
I have written a script that fires a jQuery POST to retrieve data from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.