Mysql启动时执行文件init-file的使用

时间:2018-06-01 15:35:36   收藏:0   阅读:2066

可以在配置文件里指定mysql启动以后初始执行的SQL文件, 其语法是:

在[mysqld]下指定:

init-file="D:/mysql/test.sql",  后面为具体的sql文件值。

注意下边两点就行了:

1. 确保你的mysqld 编译的时候没有加  --disable-grant-options 开关。

2. 确保init-file指定的脚本每行是一个具体的可以执行的语句。

技术分享图片

废话不多说(上面截图我使用的mysql7)。直入正题:test.sql为:

use test;  
begin;  
create table if not exists test123(id int);  
insert into test123 values(1);  
insert into test123 values(2);  
select * from test123;  
-- drop table test123;  
end;  

 启动完mysql以后,得到查询可以看到

技术分享图片

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!