8

我正在尝试恢复一个 13G 大的 sql 转储文件。我第一次在xampp中使用phpAdmin,它说大小太大。然后我使用了大转储,仍然收到错误消息“我无法在 xx.sql 中查找”。我在网上查到,这意味着文件太大。然后我开始使用命令行。mysql -u username -p database < location/to/your/dump.sql 似乎它正在工作,因为它要求输入密码,我直接按Enter,因为我没有密码。现在我可以看到“_”一直在闪烁,我假设这意味着它正在工作。但是我无法检查以确保,而且已经需要一段时间了。

有没有办法确保它正常工作?我真的很感谢你的帮助!!TJ

4

3 回答 3

7

Another way to restore files with the mysql command line client is like this:

$ mysql -u username -p database 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2933685
--8<-- snip --8<--

mysql> source location/to/your/dump.sql 

The source command will read the dump file and apply it to the server just like the < redirection operator, but with two differences: you will see continuous "x rows affected" messages scrolling by, giving you some indication that progress is actually occurring. The down-side of this method is that, unlike the method using < redirection, if there are any errors in the dump file, the command line client will just try to keep going, which is not always what you want. Still, it might be a viable approach.

Or... the way you're doing it now, if you can see the connection in the processlist, check the value for Sleep. If the value is constantly 0, then some kind of activity is occurring.

于 2013-11-01T04:12:28.163 回答
0

试试这个技术

连接远程MySql数据库后……</p>

  • 生成查询以创建源数据库的表模式、过程和函数
  • 生成查询以查找所有表的所有索引,但源数据库的外键约束除外
  • 生成查询以删除在步骤 2 中找到的所有索引
  • 生成查询以插入源数据库的所有数据
  • 生成查询以创建在步骤 2 中找到的所有索引
  • 将上述顺序中的所有查询写入一个 .sql 文件,这是您的新 MySql 备份。使用 LZ4 压缩对其进行压缩。
  • 现在只需使用 MySql 的正常恢复实用程序从该文件恢复数据库。

参考:http ://axiomnext.com/blog/how-to-restore-large-mysql-database-faster/

于 2014-06-12T10:04:32.513 回答
0

我恢复类似大小的文件

  1. 大约需要 4-5 小时,可能更多取决于您拥有的键和约束的性质
  2. 您可以随时检查进程列表以查看它是否有效。
  3. tail -f mysql 常规日志,并确保它记录任何查询。这是查看它是否工作的最简单方法。需要注意的是,这会使一切速度减慢 100% +
于 2013-11-01T01:57:29.357 回答