Usage example of the init-file option of MySQL
Init-file is the script loaded when MySQL is started.
There are two notes.
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 has a specific statement.
Use the following method to directly add it to the configuration file, such as my. CNF.
Add:
[Server], [mysqld], or [mysqld_safe]
Init-file = "your file location"
# The following options will be passed to all MySQL clients
[Server]
Init-file =/usr/local/mysql567/init. File
[Root @ ambow-School-system-hylm bin] # ll/usr/local/mysql567/init. File
-RW ---- 1 MySQL 92 DEC/usr/local/mysql567/init. File
[Root @ hylm bin] CAT/usr/local/mysql567/init. File
Use test;
Insert Chen select substr (passid, 1, 7) A, max (passid) as AA from user group by;
[Root @ hylm bin] #
Mysql> show create table Chen \ G;
* *************************** 1. row ***************************
Table: Chen
Create Table: Create Table 'chen '(
'Pkey' char (8) default null,
'Value' char (25) default null
) Engine = memory default charset = utf8
1 row in SET (0.00 Sec)
Error:
No query specified
Mysql> show create table user \ G;
* *************************** 1. row ***************************
Table: User
Create Table: Create Table 'user '(
'Passid' char (25) default null
) Engine = MyISAM default charset = utf8
1 row in SET (0.00 Sec)
Error:
No query specified
Mysql> select * from user;
+ ----------------- +
| Passid |
+ ----------------- +
| Apt1212100000 |
| Apt1212100002 |
| Apt1212100003 |
| Cisco1212100001 |
| Cisco1212100002 |
| Cisco1212100003 |
| Tmp1212100001 |
| Tmp1212100002 |
| Tmp1212100003 |
+ ----------------- +
9 rows in SET (0.00 Sec)
Mysql>
After restarting, you can see the following:
Mysql> select * From Chen;
+ --------- + --------------- +
| Pkey | value |
+ --------- + --------------- +
| Apt1212 | apt1212100003 |
| Cisco12 | cisco1212100003 |
| Tmp1212 | tmp1212100003 |
+ --------- + --------------- +