简体   繁体   English

用mysqldump恢复,但数据在哪里?

[英]restoring with mysqldump, but where is the data?

Ok, so I'm in need to restore a table and I do: 好的,所以我需要恢复一个表,我这样做:

mysqldump --opt database table_name < table_name.sql 

I hit enter and Done! 我点击进入和完成! Well, not really, when I go to see if there is anything on the table it show 0 records. 嗯,不是真的,当我去看看桌子上是否有任何东西它显示0条记录。

I have look into the table_name.sql and I see two records. 我查看了table_name.sql,我看到了两条记录。

What am I doing wrong? 我究竟做错了什么?

mysqldump is the wrong command for restoring from a backup. mysqldump是从备份还原的错误命令。

You need to run mysql , as in, the mysql client. 你需要运行mysql ,就像在mysql客户端一样。 It's generally something like this: 它通常是这样的:

mysql -u username -p database_name < sqlfile.sql

That will use your file as input to the mysql client, which subsequently executes the SQL. 这将使用您的文件作为mysql客户端的输入,随后执行SQL。

mysqldump just exports the data to an SQL script. mysqldump只是将数据导出到SQL脚本。 You can restore with this: 你可以用这个恢复:

mysql db < file.sql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM