mysql 控制台内的 MySQL 转储
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9460729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL dump inside mysql console
提问by John Kim
Is there SQL command where you can do MySQL dump inside the MySQL console?
是否有可以在 MySQL 控制台内进行 MySQL 转储的 SQL 命令?
I tried mysqldump but it does not work...
我试过 mysqldump 但它不起作用...
I'm trying to output into SQL file.
我正在尝试输出到 SQL 文件中。
回答by Stephen Senkomago Musoke
You cannot run mysqldump within a MySQL console since mysqldump is an external command like the mysql console.
您不能在 MySQL 控制台中运行 mysqldump,因为 mysqldump 是一个类似于 mysql 控制台的外部命令。
Exit the console and use the mysqldump command as follows:
退出控制台,使用mysqldump命令如下:
mysqldump -u username -p -h hostname (or ip address) databasename > sqlfilename
mysqldump -u 用户名 -p -h 主机名(或 IP 地址)数据库名 > sqlfilename
It will ask for password.
它会要求输入密码。
More details of mysqldump can be found at http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
mysqldump 的更多细节可以在http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html找到
回答by Ranieri Machado
use \!
:
使用\!
:
\! mysqldump -u username -p database > database_dump.sql