裏面的my.cnf我指定:mysqldump的工具不包括作爲SQL_MODE在my.cnf輸出
sql-mode = STRICT_ALL_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_VALUE_ON_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO,ONLY_FULL_GROUP_BY
然後我重新啓動MySQL服務器:
sudo systemctl restart mysql
然後我檢查的價值SQL_MODE變量:
show variables like '%sql_mode%';
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Variable_name | Value |
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| sql_mode | STRICT_ALL_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_VALUE_ON_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO,ONLY_FULL_GROUP_BY |
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
然後我甩MyDatabase的與命令:
mysqldump --user root --password=root --host=localhost --add-drop-table --add-locks --allow-keywords --comments --complete-insert --create-options --disable-keys --extended-insert --lock-tables --quick --quote-names --routines --set-charset --dump-date --tz-utc --verbose --databases mydatabase
然後我看到輸出:
... omitted
/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
... omitted
預期輸出:
... omitted
/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='STRICT_ALL_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_VALUE_ON_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO,ONLY_FULL_GROUP_BY' */;
... omitted
有什麼不對?
嗨。謝謝您的回答。據我所知,mysqldump的強制設置SQL_MODE = NO_AUTO_VALUE_ON_ZERO有一個控制器導入環境,如你所說。 – yivo