# 导入本地数据文件
mysql --defaults-extra-file=/home/my.cnf db-demo
-e "load data infile '/home/e.sql'
into table untitled
fields terminated by ','
lines terminated by'\r\n' # 数据行之间以\r\n分隔
"
# 配置空密码
/home/my.cnf
[mysql]
user=root
password=lhadmin
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# 查询输出
select * from untitled into outfile '/var/lib/mysql-files/e.sql'
fields terminated by ',';
1
2
2
提示
secure-file-priv的值有三种情况:
secure_file_prive=null ––限制mysqld 不允许导入导出
secure_file_priv=/path/ – --限制mysqld的导入导出只能发生在默认的/path/目录下
secure_file_priv=’’ – --不对mysqld 的导入 导出做限制
step3:查看你的secure-file-priv设置:
show variables like ‘%secure%’;