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.
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
Loop the result and insert to your other tables, create if it does not exist:
The easiest way is using DB Admin Tool like SQLYog, Navicat, etc.