How do you use MySQL#39;s source command to import large files in windows(windows下如何使用mysql的source命令导入大文件)
问题描述
我有一个大 (~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.
使用 < 给出了通用的 MySQL 语法错误,而使用 source 给出了一个稍微更有希望的 failed to open file 'file_name.sql', error: 2 所以我倾向于认为 source 命令是在正确的轨道上.
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 作为本地主机服务器(请注意,我只是尝试在本地主机上导入此文件,以便我可以执行 sql).我尝试将文件放在 xamppmysqlin 和 xamppmysqldatadatabase_name 中.
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 xamppmysqlin and xamppmysqldatadatabase_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:xamppmysqlinmysql -u {username} -p {databasename} < file_name.sql
这篇关于windows下如何使用mysql的source命令导入大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:windows下如何使用mysql的source命令导入大文件
基础教程推荐
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 无法解决整理冲突 2021-01-01
