北城已荒凉 2013-07-16 00:43 采纳率: 0%
浏览 421
已采纳

如何使用 MySQL 中的命令行导入 SQL 文件?

I have a .sql file with an export from phpMyAdmin. I want to import it into a different server using the command line.

I have a Windows Server 2008 R2 installation. I placed the .sql file on the C drive, and I tried this command

database_name < file.sql

It is not working I get syntax errors.

  • How can I import this file without a problem?
  • Do I need to create a database first?

转载于:https://stackoverflow.com/questions/17666249/how-to-import-an-sql-file-using-the-command-line-in-mysql

  • 写回答

28条回答 默认 最新

  • 胖鸭 2013-07-16 00:48
    关注

    Try:

    mysql -u username -p database_name < file.sql
    

    Check MySQL Options.

    Note-1: It is better to use the full path of the SQL file file.sql.

    Note-2: Use -R and --triggers to keep the routines and triggers of original database. They are not copied by default.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(27条)

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码