创建表时表不存在吗?

时间:2021-08-14 08:19:09

I'm trying to import a SQL dump to another server. It fails on the first line. I'm first creating the exp_actions table and then inserting a bunch of data into it, but I get this really weird error.

我正在尝试将一个SQL转储导入到另一个服务器。它在第一行失败了。我首先创建exp_actions表,然后向其中插入一些数据,但是我得到了一个非常奇怪的错误。

SQL query:

--
-- Database: `ee_cmssite`
--
-- --------------------------------------------------------
--
-- Table structure for table `exp_actions`
--
CREATE TABLE  `exp_actions` (

 `action_id` INT( 4 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
 `class` VARCHAR( 50 ) NOT NULL DEFAULT  '',
 `method` VARCHAR( 50 ) NOT NULL DEFAULT  '',
PRIMARY KEY (  `action_id` )
) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =21;

MySQL said: 

#1146 - Table 'site_ee.exp_actions' doesn't exist 

Why doesn't it exist? I just instructed it to be created. I'm completely baffled. I've tried with and without IF_NOT_EXISTS

为什么它不存在吗?我只是命令它被创建。我完全困惑。我曾经尝试过,也尝试过不存在if_not_exist

3 个解决方案

#1


2  

If anyone else comes across this seemingly bizarre error - see https://*.com/a/11696069 for the solution.

如果有人遇到这个看似奇怪的错误,请参见https://*.com/a/11696069。

I had the same symptoms and the cause was the same - moving to a new machine I took the old short-cut of simply copying the databases from the mysql/data directory that I needed directly into the new machine, however some were newer InnoDb types. This causes the Create Table throws table doesn't exist error. I had to drop the database and recreate it, then import from an sql dump.

我有同样的症状,原因也是一样的——搬到一台新机器上,我采用了从mysql/data目录直接复制数据库到新机器的老方法,但是有些是较新的InnoDb类型。这导致创建表抛出表不存在错误。我必须删除数据库并重新创建它,然后从sql转储导入。

#2


0  

According to the SQL script, the table exists in another database:

根据SQL脚本,该表存在于另一个数据库中:

--

- - -

-- Database: ee_cmssite

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

-- Table structure for table exp_actions

—表exp_actions的表结构

try to use ee_cmssite database instead.

尝试使用ee_cmssite数据库。

#3


0  

While the error is not clear, I think this is related to the missing USE at the beginning of the file. mysqldump doesn't add a USE statement when you dump a single db. So you should add:

虽然错误不清楚,但我认为这与文件开头的未使用有关。在转储单个db时,mysqldump不会添加使用语句。所以你应该添加:

USE `ee_cmssite`;

#1


2  

If anyone else comes across this seemingly bizarre error - see https://*.com/a/11696069 for the solution.

如果有人遇到这个看似奇怪的错误,请参见https://*.com/a/11696069。

I had the same symptoms and the cause was the same - moving to a new machine I took the old short-cut of simply copying the databases from the mysql/data directory that I needed directly into the new machine, however some were newer InnoDb types. This causes the Create Table throws table doesn't exist error. I had to drop the database and recreate it, then import from an sql dump.

我有同样的症状,原因也是一样的——搬到一台新机器上,我采用了从mysql/data目录直接复制数据库到新机器的老方法,但是有些是较新的InnoDb类型。这导致创建表抛出表不存在错误。我必须删除数据库并重新创建它,然后从sql转储导入。

#2


0  

According to the SQL script, the table exists in another database:

根据SQL脚本,该表存在于另一个数据库中:

--

- - -

-- Database: ee_cmssite

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

-- Table structure for table exp_actions

—表exp_actions的表结构

try to use ee_cmssite database instead.

尝试使用ee_cmssite数据库。

#3


0  

While the error is not clear, I think this is related to the missing USE at the beginning of the file. mysqldump doesn't add a USE statement when you dump a single db. So you should add:

虽然错误不清楚,但我认为这与文件开头的未使用有关。在转储单个db时,mysqldump不会添加使用语句。所以你应该添加:

USE `ee_cmssite`;