使用 XAMP 导入 mysql 时出现问题
最初我使用 easyPHP (windows),然后我切换到 mac 并使用 MAMP。 我每隔一段时间就在重新格式化之前存档我的数据库。 导出是通过进入 phpMyAdmin 的根目录并使用导出功能来完成的。 现在我尝试导入数据时收到此错误“#1044 - 用户'root'@'localhost'访问数据库'information_schema'被拒绝”。 做其他事情时我遇到了错误,例如 “#1146 - 表 'test_db.COLLATION_CHARACTER_SET_APPLICABILITY' 不存在”、“#1146 - 表 'test_db.CHARACTER_SETS' 不存在”和“#1146 - 表 'test_db.COLUMNS' 不存在”和“# 1046 - 未选择数据库“
如何让 MAMP 导入并忽略任何访问错误并继续,以便我的数据库填充到之前的状态? 我不想编写一个应用程序来执行此操作,但如果我必须使用什么库来解析 sql 转储中的 sql 语句? 看起来并不难解析。 看起来像是用分号分隔语句。 但是逃逸和无法逃逸的问题又如何呢? 我该如何处理?
originally i was using easyPHP (windows) then i switch to mac and used MAMP.
i archive my db every once in a while and right before i reformatted. The export was made by going into the root of phpMyAdmin and using the export function. Now i am trying to import the data i get this error "#1044 - Access denied for user 'root'@'localhost' to database 'information_schema'". Doing other things i got errors like
"#1146 - Table 'test_db.COLLATION_CHARACTER_SET_APPLICABILITY' doesn't exist", "#1146 - Table 'test_db.CHARACTER_SETS' doesn't exist " and "#1146 - Table 'test_db.COLUMNS' doesn't exist" and "#1046 - No database selected"
How do i get MAMP to import and ignore any access errors and continue so my DB is filled to the previous state? I rather not write an app to do this but if i had to what libs would i use to parse the sql statements in the sql dump? It doesnt look hard to parse. It looks like a semicolon separates the statements. But what about escape and unescape issues? how do i handle that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一个错误表明您的设置存在严重问题。 information_schema 是一个内部数据库,用于保存有关系统其他部分的数据(元数据)。 您应该尝试重新安装 MySQL 服务器(甚至整个 MAMP)。
其次:可以使用 mysql 命令行客户端导入转储文件,如下所示:
要记住的一件事是,需要在恢复转储之前创建“test_db”。 另一个可能的问题可能是转储/恢复是由不同版本的 MySQL 完成的(即 5.0 与 5.1)。 为此,您可以尝试在 mysql 命令行中使用 --force 命令来跳过失败的执行,但请注意,这可能无法正确恢复您的数据。
The first error indicates that something is very wrong with your setup. information_schema is an internal DB which keeps data about other parts of the system (meta-data). You should try reinstalling your MySQL server (or even MAMP as a whole).
Second of all: the dump files can be imported using the mysql command line client like this:
One thing to remember is that "test_db" needs to be created before the dump is restored. An other possible problem might be that the dump/restore is being done by different versions of MySQL (ie. 5.0 vs 5.1). For this you could try the --force command in the mysql command line to skip over failed executions, however be aware that this might not correctly restore your data.