load_file函数


执行select load_file('/home/greatdb/a.txt');  死活返回null。

捯饬半天,总算搞明白了,要注意以下四点:

1. 跟greatdb 数据库服务的启动用户有关,

./bin/greatdbd_safe --defaults-file=my3306-8019.cnf --user=greatdb &   2.跟操作系统用户有关 使用greatdb用户进行测试。

3.跟数据库登录用户有关

greatdb -h127.0.0.1 -P3306 -ugreatdb -pgreatdb  --binary-as-hex=false

登录数据库greatdb用户 进行测试

3.跟系统变量sercure_file_priv有关

参数文件中设置

查询此系统变量为NULL时,就需要修改。

总之:服务启动使用用户greatdb,切换到操作系统用户greatdb,登录数据库使用greatdb ,设置参数secure_file_priv为空,这样就能成功读取文件。