可以在配置文件里指定mysql啟動以后初始執行的SQL文件, 其語法是:
在[mysqld]或者[server]下指定:
init-file=D:/mysql-5.5.28-winx64/abc.sql, 后邊為具體的sql文件值
注意下邊兩點就行了:
1. 確保你的mysqld 編譯的時候沒有加 --disable-grant-options 開關。
2. 確保init-file指定的腳本每行是一個具體的可以執行的語句。
為了示例:
abc.sql為:
復制代碼 代碼如下:
use test;
begin;
create table if not exists t123(id int);
insert into t123 values(1);
insert into t123 values(2);
select * from t123;
-- drop table t123;
end;
復制代碼 代碼如下:
mysql> use test;
Database changed
mysql> select * from t123;
+------+
| id |
+------+
| 1 |
| 2 |
+------+
2 rows in set (0.00 sec)
新聞熱點
疑難解答