2014-04-23 8 views
0

테이블을 잠그는 동안 mysqldump를 생성하는 간단한 bash 스크립트를 작성했습니다. 나는이 스크립트를플러시 테이블 읽기 잠금 옵션을 사용하여 mysqldump를 생성하는 중 오류가 발생했습니다.

mysqldump: Couldn't find table: "TABLES" 

을 실행할 때

# Generate mysqldump that will be used on client side 
Q1="USE test;" 
Q2="FLUSH TABLES WITH READ LOCK;" 
Q3="SYSTEM /usr/bin/mysqldump -u root --master-data=1 --opt ssc > /var/opt/backup.sql" 
Q4="UNLOCK TABLES;" 
SQL="${Q1}${Q2}${Q3}${Q4}" 

# Run the mysql query commands 
$MYSQL -uroot -e "$SQL" 
SQL="${Q1}${Q2}${Q3}${Q4}" 

는이 오류를 볼 수 있지만 내가 기대 작품으로 MySQL의 프롬프트 모두에서 수동으로이 명령을 실행하면 이상한 일이다.

mysql> use test; 
Reading table information for completion of table and column names 
You can turn off this feature to get a quicker startup with -A 

Database changed 
mysql> flush tables with read lock; 
Query OK, 0 rows affected (0.00 sec) 

mysql> SYSTEM /usr/bin/mysqldump -u root --master-data=1 --opt test > /var/opt/backup.sql 
mysql> unlock tables; 
Query OK, 0 rows affected (0.00 sec) 

mysql> unlock tables; 
Query OK, 0 rows affected (0.00 sec) 

mysql> Bye 

아무 것도 알려지지 않은 사람이 알려주시겠습니까?

답변

1

Q3를 세미콜론으로 닫지 않았습니다. 아래에 문을 참조하십시오

Q3="SYSTEM /usr/bin/mysqldump -u root --master-data=1 --opt ssc > /var/opt/backup.sql" 

이어야

Q3="SYSTEM /usr/bin/mysqldump -u root --master-data=1 --opt ssc > /var/opt/backup.sql;"