Mysql执行单个sql脚本、执行多个sql脚本

执行单个脚本 

1、打开mysql命令窗口

source test.sql

source 不带分号

执行多个脚本

1、待执行的sql文件为test1.sql、test2.sql、test.sql、4.sql等

2、写一个总的sql文件例如:all.sql文件:

source test1.sql
source test2.sql
source test3.sql
source test4.sql


3、在mysql下执行

source batch.sql

注意sql路径问题以及mysql 的版本,博主使用的是5.7,注意不要分号

直接窗口运行

【Mysql的bin目录】\mysql –u用户名 –p密码 –D数据库<【sql脚本文件路径全名】
 

 D:\MySQL\bin\mysql –uroot –p123456 -Dtest<C:\test.sql

猜你喜欢

转载自blog.csdn.net/xljx_1/article/details/101363583