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

  • SEARCH
  • Home
  • 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 8901565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:23:19+00:00 2026-06-15T01:23:19+00:00

I have a little problem. I have two MySQL databases, and I want to

  • 0

I have a little problem. I have two MySQL databases, and I want to move all of the tables from one into the other, except when I use the normal PHPMyAdmin export, it comes up with an error because of my ID column. How can I copy the whole database into the other one, except without copying that one table in PHPMyAdmin? Also, I can’t just copy tables manually because I have alot of tables. I know that this may involve looping over all of the tables in a database. Anybody know of a way to do that (I am OK if it uses PHP)?
All of the tables are exactly the same in structure, and follow this structure:

id int NOT NULL AUTO_INCREMENT, # The one I don't want to copy (it is also a primary key)
col1 varchar(5), # Want to copy all of these.
col2 varchar(15),
col3 varchar(1000),
col4 varchar(20)

All I am wanting to do is copy all of the tables from one database to another database, except without copying the id column of each entry. So, for example, if I was just to add one entry manually I would use CREATE TABLE IF NOT EXISTS mytable ..., and then INSERT INTO mytable (col1, col2, col3, col4) VALUES (value1, value2, value3, value4). Note that I am not inserting the id column.

  • 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-15T01:23:24+00:00Added an answer on June 15, 2026 at 1:23 am

    You can crete PHP script to get all of your tables and do looping to insert into your new tables. If the structure is the same then it should be easier to copy all of them. Here the ideas:

    Get all tables

    $sql = "SHOW TABLES FROM DB1";
    $query = mysql_query($sql);    
    
    // save the result as $old_tables
    
    $sql = "SHOW TABLES FROM DB2";
    $query = mysql_query($sql);    
    
    // save the result as $new_tables
    

    Loop the result and insert to your other tables, create if it does not exist:

    foreach($old_tables as $table){
        if(!in_array($table, $new_tables)){
            // create table with the name $table in DB2
        }
    
        $sql = "INSERT INTO DB2.$table(col1, col2, col3, col4) SELECT col1, col2, col3, col4 FROM  DB1.$table";
        mysql_query($sql);
    }
    

    The easiest way is using DB Admin Tool like SQLYog, Navicat, etc.

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

Sidebar

Related Questions

I have a little problem. I want to pass two variables from PHP to
I've got a little problem by subtracting two datetime objects from each other. I
Hello there i am having little problem. I have two tables in my database.
I have this little problem. My client wanted two distinct swf on a web
I using dropkick js to style dropdown forms but have one little problem. What
I have a little C# problem. I have two classes ClassA and ClassB defined
I have two tiny little problems; 1 . I want to add a previous
I have a little problem resigning the keyboard. I have a table with two
i have a litte problem! i want to fetch the last 3 rows from
I have a little problem with my MysqlConnection objets. I have those two connection

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.