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 8063475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:03:06+00:00 2026-06-05T11:03:06+00:00

How do I backup a MySQL database using just queries? I mean, PHP’s system()

  • 0

How do I backup a MySQL database using just queries?
I mean, PHP’s system() function is disables for security reasons, thus I cannot invoke mysqldump.

For table structure I use this:

SHOW CREATE TABLE table_name

But how about table data? Does a predefined SQL command exist? I tried with SELECT ... INTO var_list, but I cannot get this to work (SELECT ... INTO OUTFILE is not suitable for me, as the db host is different from the server I have access to).

Thanks for your help, and sorry for being such a noob, but this is my first question here! 🙂

  • 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-05T11:03:08+00:00Added an answer on June 5, 2026 at 11:03 am

    It should be pretty straightforward to create INSERT statements in your PHP code from a SELECT * FROM table query. Here’s an example:

    $db = new PDO('mysql:dbname=DATABASE;host=HOST', 'USER', 'PASSWORD');
    $result = $db->query('SELECT * FROM table');
    
    $columns = array();
    for($i = 0; $i < $result->columnCount(); $i++) {
      $column = $result->getColumnMeta($i);
      $columns[] = sprintf('`%s`', $column['name']);
    }
    $colstring = implode(',', $columns);
    
    $rows = $result->fetchAll(PDO::FETCH_NUM);
    $inserts = array();
    foreach($rows as $r) {
      $values = array_map(function($e) use ($db) {
          return $db->quote($e);
        },
        $r);
      $valstring = implode(',', $values);
      $inserts[] = sprintf('INSERT INTO table (%s) VALUES (%s)',
                           $colstring,
                           $valstring);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the Database Backup script by David Walsh( http://davidwalsh.name/backup-mysql-database-php ) to backup
I'm using this command to backup a MySql database: public function backup() { $backup
I am using mysqldump to backup mysql database. Now I just need to use
I need to backup the MySQL database on my current system. I am using
How can I make a perfect backup of mysql database using mysqldump? When I
I want to backup my database using mysql dump. This is the code I
i am using mysql as my database server. I want to have a backup
I got this code from this site: http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/using-php-to-backup-mysql-databases.aspx But I'm just a beginner so
Is possible? I plan to backup mysql database using vb.net. If you know any
I am trying to backup the database using mysql and c# by using following

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.