[英]php / mysql access denied with select into outfile
I have the following php code: 我有以下php代码:
<?php
$hostname="db.";
$database="db..";
$username="db...";
$password="pw...";
$mysql = mysql_connect($hostname, $username, $password);
if(!$mysql)
echo 'Not conneted to the database...' . mysql_error() ;
else
echo 'Connected to the database...' ;
// select the appropriate database
$mysqldb = mysql_select_db( $database );
if(!$mysqldb)
die('Could not select the database...' . mysql_error());
else
echo '<br /><br />Connected to database...<br /><br />' ;
$chk_table_access = 'select * from table_name where 1';
$chk_access = mysql_query($chk_table_access);
echo $chk_table_access . '<br /><br />';
if (!$chk_access)
echo 'Could not access table: ' . mysql_error() ;
else
echo 'Table was accessed..<br /><br />' ;
$backup = 'SELECT * INTO OUTFILE "result.csv" FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY ';
$backup = $backup . "'" . '"' . "'" ;
$backup = $backup . ' FROM cities WHERE 1';
echo $backup . '<br /><br />';
$bk_success = mysql_query($backup);
if (!$bk_success)
echo 'The backup was not successful. Reason: ' . mysql_error();
?>
The program runs fine on localhost, but when I run it from my web site I get the following error: Access denied for user 'dbo????????'@'%' (using password: YES). 该程序可以在localhost上正常运行,但是当我从网站上运行该程序时,出现以下错误:用户'dbo ????????'@'%'的访问被拒绝(使用密码:是)。 The web help is not much help.
Web帮助不是很多帮助。
I do get the "Table was accessed.." message so I'm accessing the table okay. 我确实收到“表已被访问..”消息,所以我可以正常访问表。 I do frwite to the directory every day without errors.
我每天都浏览目录,没有错误。 I understand why it doesn't work in phpMyAdmin.
我了解为什么它在phpMyAdmin中不起作用。 I'm a little stumped.
我有点难过。 It's also the first question I've asked on this forum although I come here often for help.
这也是我在此论坛上提出的第一个问题,尽管我经常来这里寻求帮助。 You guys (ladies included) rock.
你们(包括女士们)摇滚。 Thanks in advance, Steve
预先感谢,史蒂夫
Your MySQL user apparently lacks the FILE
privilege . 您的MySQL用户显然缺少
FILE
特权 。
Does the MySQL server run on the same machine as the web server? MySQL服务器是否与Web服务器在同一台计算机上运行? If both servers run on different machines, you can stop right here: Even with
FILE
privilege, the output file would be created on the database server (and would probably inaccessible from the web server). 如果两个服务器都在不同的计算机上运行,则可以在此处停止:即使具有
FILE
特权,输出文件仍将在数据库服务器上创建(可能无法从Web服务器访问)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.