如何在MySQL中使用命令行导入SQL文件? [英] How to import an SQL file using the command line in MySQL?

查看:324
本文介绍了如何在MySQL中使用命令行导入SQL文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.sql文件,从phpMyAdmin导出。我想使用命令行将其导入其他服务器。

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

我有一个 Windows Server 2008 R2安装。我把.sql文件放在C盘上,我试过这个命令

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?

推荐答案

尝试:

mysql -u username -p database_name < file.sql

检查 MySQL选项

注意:最好使用SQL的完整路径文件 file.sql

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

这篇关于如何在MySQL中使用命令行导入SQL文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆