在MySQL中运行.sql文件 [英] To run a .sql -file in MySQL

查看:173
本文介绍了在MySQL中运行.sql文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题基于此线程.

我跑步失败

sudo mysql 
\. /users/cs/SO_db/posts.sql 

我得到了错误

ERROR 1146 (42S02): Table 'personal.posts' doesn't exist

MySQL手册

五个字符的SQLSTATE值 ('42S02').这些值由 ANSI SQL和ODBC以及更多 标准化.并非所有的MySQL错误 数字映射到SQLSTATE错误 代码.值"HY000"(常规 错误)用于未映射的错误.

A five-character SQLSTATE value ('42S02'). The values are specified by ANSI SQL and ODBC and are more standardized. Not all MySQL error numbers are mapped to SQLSTATE error codes. The value 'HY000' (general error) is used for unmapped errors.

错误:1146 SQLSTATE:42S02 (ER_NO_SUCH_TABLE)

Error: 1146 SQLSTATE: 42S02 (ER_NO_SUCH_TABLE)

消息:表'%s.%s'不存在

Message: Table '%s.%s' doesn't exist

如何解决错误消息?

推荐答案

正如我在您引用的帖子中提到的那样,您需要首先创建表. 在所需的列上浏览XML或SQL输出.例如这是一个可以保存badges.xml输出的表(我现在没有其他可用的..)

As I mentioned in the post you referenced, you NEED to create the tables first. Peek at the XML or the SQL output on what columns you need. e.g. here is a table that can hold the output from badges.xml (I don't have the others available right now..)

CREATE TABLE `badges` (
  `Id` int(11) NOT NULL default '0',
  `UserId` int(11) not NULL,
  `Date` datetime not  NULL,
  `Name` varchar(32) not NULL,
  PRIMARY KEY  (`Id`),
  KEY `Date` (`Date`),
  KEY `UserId` (`UserId`)
) ;

这篇关于在MySQL中运行.sql文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆