判断读取文件是否有权限 and (select count() from mysql.user>/0) (1)若返回正确,则文件有权可读 (2)若返回错误,则需要管理员给数据库账户降权 注意:如果NTFS设置得当,是没有权限读取文件的,当遇到administrators才能访问的文件,使用者就别想load_file出来
如:load data infile’/tml/t0.txt’ignore into t0 character set gbk fields teminated by lines terminated by’\n’ character set gbk是字符集设置为gbk,fields teminated by 为每一项数据之间的分隔符,lines terminated by’\n’是行 的结尾符
两种利用方式: (1)直接将select内容导入到文件中 如:select version() into outfile”c:\phpnow\htdocs\test.php”,version()可以换成一句话代码 (2)修改文件结尾 如: select version() into outfile”c:\phpnow\htdocs\test.php”lines terminated by 0x16进制文件
secure_file_pri参数会限制load_file(),select…into outfile””,load data infile等函数,有三种情况: (1)secure_file-pri=null时表示限制mysql,不准导入导出文件(mysql中的默认值) (2)secure_file_pri=目录时限制mysql导出导入文件只发生在这个目录下 (3)secure_file_pri=没有具体值时,不限制mysql导出导入文件