Chinaunix首页 | 论坛 | 博客
  • 博客访问: 674781
  • 博文数量: 176
  • 博客积分: 4791
  • 博客等级: 上校
  • 技术积分: 1921
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-24 18:47
个人简介

it江湖漂,怎能不挨刀;一朝机器当,看你怎么着!

文章分类

全部博文(176)

文章存档

2014年(2)

2012年(17)

2011年(27)

2010年(18)

2009年(6)

2008年(21)

2007年(43)

2006年(42)

分类: LINUX

2008-12-30 15:58:18

关于MySQL的init-file选项的用法实例

init-file 是在MySQL启动的时候加载的脚本。
有两个要注意的。
1. 确保你的mysqld 编译的时候没有加  --disable-grant-options 开关。
2. 确保init-file指定的脚本每行一个具体的语句。

使用方法如下,直接添加到配置文件,比如my.cnf.
添加:
[server] 或者 [mysqld] 或者 [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-rw---- 1 mysql mysql 92 Dec 15:43 /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 a;
[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>
重起后就可以看到如下:
mysql> select * from chen;
+---------+-----------------+
| pkey    | value           |
+---------+-----------------+
| apt1212 | apt1212100003   |
| cisco12 | cisco1212100003 |
| tmp1212 | tmp1212100003   |
+---------+-----------------+

 

 

 

 

阅读(1588) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~