Usage of mysql initial execution File

Source: Internet
Author: User

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:
Copy codeThe Code is as follows:
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, obtain the query result.:
Copy codeThe Code is as follows:
Mysql> use test;
Database changed
Mysql> select * from t123;
+ ------ +
| Id |
+ ------ +
| 1 |
| 2 |
+ ------ +
2 rows in set (0.00 sec)

After the second startup, the 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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.