php - How to Import Multi-Database MySQLdump with 'DROP TABLE IF EXISTS'? -
i want copy bunch of db's server1 server2 , want drop db's on server2 conflict imported db's, import db's.
i'm using import:
mysql -u root -p[password] < a_bunch_of_dbs.sql
i used phpmyadmin perform several exports totally unusable.
the problem phpmyadmin either put:
drop database `database1`;
(it results in error #1008 - can't drop database 'database1'; database doesn't exist)
or:
create database `database1`;
(it results in error #1007 - can't create database 'database1'; database exists)
but not:
drop database if exists `database`; create database if not exists `database1`;
(obviously "if not exists" redundant liked there reassurance)
so, solve either need command line options or need find out phpmyadmin creates query strings , add "if exists" drop table option , solve everything.
any ideas? thank you.
take advantage of mysql backup , restore tools in dbforge studio mysql. turn option 'include if exists in drop statement' on , script this:
-- -- definition database database1 -- drop database if exists database1; create database database1 character set latin1 collate latin1_swedish_ci; -- -- set default database -- use database1; -- -- definition table dept -- create table dept ( id int(11) not null auto_increment, dept_name varchar(255) default null, primary key (id) ) engine = innodb auto_increment = 2 avg_row_length = 16384 character set latin1 collate latin1_swedish_ci;
command line supported.
Comments
Post a Comment