在命令行中执行.sql文件 [英] executing a .sql file in command line

查看:298
本文介绍了在命令行中执行.sql文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这样做

mysql -uroot -p -e source F:\code\mysql\mysql-data\myHfs\test.sql  

给出:错误1049(42000):未知数据库'f:\ \code\mysql\mysql-data\myhfs\test.sql'

gives : ERROR 1049 (42000): Unknown database 'f:\code\mysql\mysql-data\myhfs\test.sql'

但是如果我进入mysql命令promt并仅使用 mysql -uroot -p ,然后键入 source F:\code\mysql\mysql-data\myHfs\test.sql ,我得到了正确的输出。

But if i go inside the mysql command promt with just the mysql -uroot -p and then type in source F:\code\mysql\mysql-data\myHfs\test.sql , i get the proper output.

以上文件的内容为:

use gregs_list;
show tables;
select * from clown_info;

编辑:执行 mysql -uroot -p < f:\\ code \\ mysql \\ mysql-data \\ myHfs \\ test.sql -t 似乎可以解决问题。

Edit : doing mysql -uroot -p < "F:\code\mysql\mysql-data\myHfs\test.sql" -t seems to solve the problem.

推荐答案

http://dev.mysql.com/doc/refman/5.0/en/mysql-batch-commands.html

mysql -uroot -p< F:\code\mysql\mysql-data\myHfs\test.sql

这篇关于在命令行中执行.sql文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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