天天看点

DOS下执行Sql脚本

在DOS下执行Sql脚本有两种方法。 

假设:用hj.sql 并放于E根目录下。

方法一:

1.写好Sql脚本 并放在目录下 例如:目录是 e盘 hj.sql脚本如下

use hongjia;

update yingshou  set payment=2680  where billno in('YS-20130131-00010','YS-20130131-00012');

update sellorder set money=2900,prodmoney=2900 where billno='XS-20130130-00008';

2.找到 Mysql的安装目录bin下

例如:D:\Program Files\MySQL\MySQL Server 5.0\bin 

3.在DOS下 执行命令

"D:\Program Files\MySQL\MySQL Server 5.0\bin \mysql" -uroot -p123456 < e:\hj.sql

注:目录中有空格,所以路径要用" "引起来。

方法二:

1.执行 sql命令 连接数据库 mysql -uroot -p123456

2.选择要操作的数据库  use hongjia;

3.执行命令 source e:\hj.sql

转载于:https://blog.51cto.com/3626090/1132069