如何使用选项从命令行导出和导入.sql文件? [英] How to export and import a .sql file from command line with options?
问题描述
不可重复!,在命令行导出过程中寻找某些功能具有phpmyadmin
我想从命令行向MySQL数据库中导入和从MySQL数据库导入.sql文件.
在MySQL中是否有用于导出.sql文件的命令?那我该怎么导入呢?
在进行导出/导入时,可能会有约束,例如启用/禁用外键检查或仅导出表结构.>
我们可以使用mysqldump
设置那些选项吗?
选项的一些示例
键入以下命令以导入sql数据文件:
$ mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
在此示例中,使用vivek作为用户名将"data.sql"文件导入博客"数据库:
$ mysql -u vivek -p -h localhost blog < data.sql
如果您有专用的数据库服务器,则将localhost主机名替换为实际的服务器名或IP地址,如下所示:
$ mysql -u username -p -h 202.54.1.10 databasename < data.sql
要导出数据库,请使用以下命令:
mysqldump -u username -p databasename > filename.sql
请分别注意<
和>
符号.
Not Duplicate! looking for some feature have phpmyadmin during export in command line
I want to export and import a .sql file to and from a MySQL database from command line.
Is there any command to export .sql file in MySQL? Then how do I import it?
When doing the export/import, there may be constraints like enable/disable foreign key check or export only table structure.
Can we set those options with mysqldump
?
some example of Options
Type the following command to import sql data file:
$ mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
In this example, import 'data.sql' file into 'blog' database using vivek as username:
$ mysql -u vivek -p -h localhost blog < data.sql
If you have a dedicated database server, replace localhost hostname with with actual server name or IP address as follows:
$ mysql -u username -p -h 202.54.1.10 databasename < data.sql
To export a database, use the following:
mysqldump -u username -p databasename > filename.sql
Note the <
and >
symbols in each case.
这篇关于如何使用选项从命令行导出和导入.sql文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!