如何使用MySQL的源命令在Windows中导入大文件 [英] How do you use MySQL's source command to import large files in windows
问题描述
我有一个大的(~150mb)sql文件,我试图导入。它太大了,无法通过PHPMyAdmin将其拆分为多个部分,并且它太大而无法通过php脚本导入,因为它在处理脚本30秒后超时。所以我正在寻找如何从MySQL命令行直接导入文件。
I have a large (~150mb) sql file that I am trying to import. It is too large to do it through PHPMyAdmin even splitting it into many pieces and it is too large to import through a php script as it times out after 30 seconds of processing the script. So I'm looking for how to directly import the file from MySQL command line.
在线搜索显示我要使用 database_name< file_name.sql
或 source file_name.sql
但我无法让其中任何一个工作。
Searching online shows that I want to either use database_name < file_name.sql
or source file_name.sql
but I can't get either of these to work.
使用<
在使用 source
时给出了通用的MySQL语法错误,给出了更有希望的无法打开文件'file_name.sql',错误:2
所以我倾向于认为源命令是在正确的轨道上。
Using <
gives the generic MySQL syntax error while using source
give a slightly more promising failed to open file 'file_name.sql', error: 2
so I am inclined to think that the source command is on the right track.
我在Windows中并使用xampp作为localhost服务器(注意我只是尝试在localhost上导入此文件以便我可以执行sql)。我已经尝试将文件放在 xampp \mysql \ bin
和 xampp \ mysql \ data \ _database_name $ c $中c>。
I am in windows and am using xampp as a localhost server (note I'm only trying to import this file on the localhost so that I can execute the sql). I've tried placing the file in xampp\mysql\bin
and xampp\mysql\data\database_name
.
任何关于如何通过MySQL命令行或任何其他方式将此.sql文件导入MySQL的建议将不胜感激。
Any suggestions of how to import this .sql file into MySQL either from the MySQL command line or by any other means would be greatly appreciated.
推荐答案
使用xampp我认为你需要在命令行使用完整路径,可能是这样的:
With xampp I think you need to use the full path at the command line, something like this, perhaps:
C:\xampp\mysql\bin\mysql -u {username} -p {databasename} < file_name.sql
这篇关于如何使用MySQL的源命令在Windows中导入大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!