mysql启动时的初始执行文件的使用
2012-11-24 08:23
447 查看
可以在配置文件里指定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为:
启动完mysql以后,得到查询:
第二次启动以后,得到结果:
在[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以后,得到查询:
mysql> use test; Database changed mysql> select * from t123; +------+ | id | +------+ | 1 | | 2 | +------+ 2 rows in set (0.00 sec)
第二次启动以后,得到结果:
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, 2012, 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)
相关文章推荐
- mysql启动时的初始执行文件的使用
- mysql 初始执行文件的使用介绍
- mysql 初始执行文件的使用介绍
- docker:mysql启动时自动执行初始建表脚本
- 使用logrotate对MySQL指定日志文件执行按天轮转备份
- 使用YUM安装并启动MySQL服务后,MySQL进程会自动在进程日志中打印root用户的初始密码
- mysql 的自动启动 使用配置文件 /etc/my.cnf
- Mysql正常启动之后默认使用的文件
- 使用bat文件执行mysql的建库操作
- 执行文件mysql使用source 命令乱码问题
- 使用Navicat for Mysql执行sql查询文件注意事项
- VS下EXE可执行文件启动代码剖析(5)使用动态运行库的EXE
- 使用C#执行MySQL的SQL文件
- 使用mysqlbinlog从二进制日志文件中查询mysql执行过的sql语句
- Mysql 将结果保存到文件 从文件中执行sql语句 记录操作过程(tee 命令的使用)
- 让docker中的mysql启动时自动执行sql文件
- 搞定使用MySQL导入外部的SQL文件执行
- idea jetty插件启动服务后,修改代码报“请求的操作无法在使用用户映射区域打开的文件执行”
- linux下执行mysql的sql文件
- 使用Process类启动新进程打开文件