MySQL SELECT..INTO OUTFILE語句只能匯出1000行的故障

feelpurple發表於2016-10-20
同事反映,客戶的一套MySQL生產庫,執行SELECT.. INTO OUTFILE語句只能匯出1000行

最初以為是系統引數被重新設定了,建議他更改系統引數

mysql> set global sql_select_limit=50000000;
Query OK, 0 rows affected (0.00 sec)

同事反映,沒有生效

登陸到資料庫,檢視系統引數,發現全域性的引數已經生效

mysql> show global variables like 'sql_select_limit';
+------------------+----------+
| Variable_name    | Value    |
+------------------+----------+
| sql_select_limit | 50000000 |
+------------------+----------+
1 row in set (0.00 sec)

檢視會話級引數,發現依然是1000

mysql> show session variables like 'sql_select_limit';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| sql_select_limit | 1000  |
+------------------+-------+
1 row in set (0.00 sec)

檢視官方文件,發現當啟動資料庫時指定了--safe-updates引數,當會話連線到資料庫後,會將sql_select_limit引數設為1000

When you use the --safe-updates option, mysql issues the following statement when it connects to
the MySQL server:
SET sql_safe_updates=1, sql_select_limit=1000, max_join_size=1000000;

重新啟動資料庫,去掉--safe-updates引數,資料庫恢復正常
mysqld_safe --defaults-file=/etc/my.cnf &

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2126826/,如需轉載,請註明出處,否則將追究法律責任。

相關文章