skip to Main Content

I have a clean new mysql database on my localhost, and also I have a project built on codeigniter PHP framework and have a copy of that project database.

However, when I import the database into my clean new database I already created I get this error message :

SQL query:


-- --------------------------------------------------------

--
-- Table structure for table `cr_addons`
--

CREATE TABLE `cr_addons` (
  `addon_id` int(11) NOT NULL,
  `addon_name` varchar(50) DEFAULT NULL,
  `price` decimal(10,2) DEFAULT NULL,
  `description` varchar(100) DEFAULT NULL,
  `addon_image` varchar(50) DEFAULT NULL,
  `status` enum('Active','Inactive') DEFAULT 'Active'
) ENGINE=InnoDB DEFAULT CHARSET=utf8
MySQL said: Documentation

#1050 - Table 'cr_addons' already exists

How could I have to delete a table where I already have an empty database!
Working on my local machine with apache and mysql (XAMPP Stack)

3

Answers


  1. Execute

    CREATE DATABASE IF NOT EXISTS `database_name`;
    USE `database_name`;
    DROP TABLE IF EXISTS `cr_addons`;
    CREATE TABLE `cr_addons` (
      `addon_id` int(11) NOT NULL,
      `addon_name` varchar(50) DEFAULT NULL,
      `price` decimal(10,2) DEFAULT NULL,
      `description` varchar(100) DEFAULT NULL,
      `addon_image` varchar(50) DEFAULT NULL,
      `status` enum('Active','Inactive') DEFAULT 'Active'
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8
    
    Login or Signup to reply.
  2. You’re new database might now be the default to be use my your client

    Try setting the default DB schema by:

    USE new_db;
    

    Or either explicitly defining in which schema the table is created in:

    CREATE TABLE new_db.`cr_addons` (
      `addon_id` int(11) NOT NULL,
      `addon_name` varchar(50) DEFAULT NULL,
      `price` decimal(10,2) DEFAULT NULL,
      `description` varchar(100) DEFAULT NULL,
      `addon_image` varchar(50) DEFAULT NULL,
      `status` enum('Active','Inactive') DEFAULT 'Active'
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8
    
    Login or Signup to reply.
  3. A simple solution I use is to re-export the database from production server. Initial export is possibly corrupt.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search