如何从 MySQL 命令行客户端创建 sql 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12055647/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:33:27  来源:igfitidea点击:

How to create a sql file from MySQL command line client

mysql

提问by Grant

I have created a database using MySQL command line client. All database files in *.frm format. Now I want to create a *.sql file from tables of this database. How to do this ? I have fond some similar questions here and none of the solutions provided worked for me.

我已经使用 MySQL 命令行客户端创建了一个数据库。*.frm 格式的所有数据库文件。现在我想从这个数据库的表中创建一个 *.sql 文件。这该怎么做 ?我在这里喜欢一些类似的问题,但提供的解决方案都没有对我有用。

回答by Mihai Iorga

mysqldump

转储

mysqldump -uroot -p database > /path/to/file/database.sql

where rootis username and you will be prompted for password, databaseis database name

哪里root是用户名,你会被提示输入密码,database是数据库名称

回答by Ed Manet

Use mysqldump to export the database.

使用 mysqldump 导出数据库。

mysqldump MyDatabase > MyDatabase.sql

http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html

http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html

回答by saket

Select your table whose .sql file you want to create -> then click on Export -> then press Go. .SQL file of that table will be created

选择要创建其 .sql 文件的表 -> 然后单击导出 -> 然后按 Go。将创建该表的 .SQL 文件