DB를 복원 할 수 있어야하는 .sql 파일을 출력하는 백업 스크립트를 만들었습니다. 데이터베이스를 복원 할 때 MySql은 구문에 이상이 있음을 알려줍니다.1 행의 MySql 구문 오류
SQL 구문에 오류가 있습니다. 1
DROP TABLE category;
CREATE TABLE `category` (
`cat_id` varchar(4) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`cat_name` varchar(15) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`cat_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
.SQL 파일이 스크립트를 사용하여 읽기 라인에서 근처 ') ENGINE =의 MyISAM DEFAULT CHARSET = 라틴'를 사용할 수있는 권리 구문에 대한 MySQL 서버 버전에 해당하는 설명서를 확인
// Read in entire file
$sql_commands_array = file($backup_file);
$file = fopen($backup_file, "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
// Loop through each line
foreach ($sql_commands_array as $current_command)
{
//echo $current_command."test";
// Add this line to the current segment
$current_query .= $current_command;
// If it has a semicolon at the end, it's the end of the query
if (substr(trim($current_command), -1, 1) == ';')
{
// Perform the query
mysql_query($current_query) or print('Error Updating DB'.mysql_error().'<br />');
// Reset temp variable to empty
}
$current_query = '';
}
이 문제를 해결하는 방법에 대한 제안. CREATE TABLE 결과는 mysql_query ('SHOW CREATE TABLE'. $ 테이블)을 사용하여 만들었습니다.
전화를 걸면 전화가 잘 작동합니다. 덤프가 만들어진 것보다 다른 버전의 MySQL에서 복원하고 있습니까? –
그것은 다른 서버 (동일한 웹 호스트 다른 서버)에서 실행 중입니다. 5.1 – mintuz
쿼리를 단독으로 실행 해 보셨습니까? 나는 여기에 내 DB를 실행하고 문제없이 테이블을 만들었습니다. 아마도 문제를 일으키는 SQL을 복원하는 다른 코드입니다. – HubblyJubbly