Use bitsCN.com for the initial execution file at mysql startup
Use of the initial execution file at mysql startup
You can specify the SQL file initially executed after mysql is started in the configuration file. Its syntax is:
In [mysqld] or [server], specify:
Init-file = D:/mysql-5.5.28-winx64/abc. SQL, followed by the specific SQL file value
Pay attention to the following two points:
1. make sure that the -- disable-grant-options switch is not added during mysqld compilation.
2. make sure that each line of the script specified by init-file is a specific executable statement.
For example:
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;
After mysql is started, query:
mysql> use test; Database changed
mysql> select * from t123;
+------+
| id |
+------+
| 1 |
| 2 |
+------+
2 rows in set (0.00 sec)
After the second startup, the following result is displayed:
Welcome to the MySQL monitor. Commands end with; or/g.
Your MySQL connection id is 2
Server version: 5.5.28 MySQL Community Server (GPL)
Copyright (c) 2000,201 2, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or'/h' for help. type'/C' to clear the current input statement.
Mysql> use test;
Database changed
Mysql> select * from t123;
+ ------ +
| Id |
+ ------ +
| 1 |
| 2 |
| 1 |
| 2 |
+ ------ +
4 rows in set (0.00 sec)
BitsCN.com