Table already exists error when trying to import sql file
I am trying to upload a backup sql file through phpMyAdmin.
create the empty db with the same db name as in my import file in phpMyAdmin then use the import function selected from within this empty db.
I get the following error message.
#1050 - Table '`db`.`t`' already exists
Inside the import file each CREATE TABLE
statement is suffixed by IF NOT EXISTS
, so why is this being reported as an error?
--
-- Database: `mbfour`
--
-- --------------------------------------------------------
--
-- Table structure for table `cars`
--
CREATE TABLE IF NOT EXISTS `cars` (
`car_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`type` varchar(200) NOT NULL,
`status` varchar(20) NOT NULL,
`capacity` varchar(5) NOT NULL,
PRIMARY KEY (`car_id`),
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `cars`
--
INSERT INTO `cars` (`car_id`, `type`, `status`, `capacity`) VALUES
(1, 'automatic', 'built', '4L'),
(2, 'automatic', 'in-production', '2L'),
(3, 'automatic', 'built', '2L'),
(4, 'automatic', 'in-production', '4L');
....
....
Is There Any Magic Happens???
After Trying Two Times Then I Import like same Way, It works
Thanks Folks.....
Please add this at the top of every query:
DROP TABLE IF EXISTS `cars`;
CREATE TABLE IF NOT EXISTS `cars`