다음은 내 데이터베이스에 텍스트 파일을 업로드해야하는 프로그램입니다. 데이터베이스에 업로드하려는 파일은 약 308MB입니다. 이 프로그램을 실행하려고하면 완전히 실행 된 것처럼 보이지만 데이터베이스를 조사 할 때 추가 된 내용이 표시되지 않습니다. 그래서 $ db-> stuff에 추가하여 어떤 오류가 발생하는지 확인하고 데이터베이스에 연결되는지 확인했습니다.PHP mysql infile not working
<?php
set_time_limit(0); // unlimited max execution time
$username = "root";
$auth = 'i-have-removed-it';
$db = $db = new mysqli("localhost", $username, $auth, 'testdb');
if(mysqli_connect_errno())
{
die("Connection could not be established");
}
print_r([
"db->connect_errno1" => $db->connect_errno,
"db->connect_error1" => $db->connect_error,
"db->errno1" => $db->errno,
"db->error1" => $db->error,
"db->sqlstate1" => $db->sqlstate,
"db->info1" => $db->info,
"db->get_warnings1" => $db->get_warnings(),
]);
$file = "./datafile_worldmap.txt";
$query = "load data infile '$file'
into table `World_Map`
character set ascii
fields terminated by '|'
lines terminated by '\r\n'
ignore 1 lines
(`GeoID`, `X`, `Y`, `Wood`, `Clay`, `Iron`, `Stone`, `Food`, `TerrainSpecificTypeID`, `TerrainCombatTypeID`, `RegionID`)
";
$result = $db->query($query);
print_r([
"db->connect_errno2" => $db->connect_errno,
"db->connect_error2" => $db->connect_error,
"db->errno2" => $db->errno,
"db->error2" => $db->error,
"db->sqlstate2" => $db->sqlstate,
"db->info2" => $db->info,
"db->get_warnings2" => $db->get_warnings(),
]);
$total_num_rows = $result->num_rows;
echo "The Results Are : <br>";
?>
출력
Array
(
[db->connect_errno1] => 0
[db->connect_error1] =>
[db->errno1] => 0
[db->error1] =>
[db->sqlstate1] => 00000
[db->info1] =>
[db->get_warnings1] =>
)
Array
(
[db->connect_errno2] => 0
[db->connect_error2] =>
[db->errno2] => 1045
[db->error2] => Access denied for user 'User'@'%%%.%%%.%%%.%%%' (using password: YES)
[db->sqlstate2] => 28000
[db->info2] =>
[db->get_warnings2] =>
)
당신은 파일 업로드 크기를 증가하는 데 필요한
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
<<email>> and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<p>Additionally, a 500 Internal Server Error
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
대신로드 데이터 infile이 데이터를 사용하십시오 infile – JYoThI
이 대답을 넣어이 그냥 필요한 것입니다. 정말 고마워 !!! – kodabear
환영합니다. 그리고 내가 대답으로 게시 – JYoThI