若是您的mysql是經過brew安裝的,那麼請php
vi /usr/local/Cellar/mysql/5.6.23/my.cnf
將mysql
max_allowed_packet = 64M
寫入保存並重啓mysql,而後進入mysql cli運行sql
show variables like 'max_allowed_packet';
能夠看到剛纔的改動是否成功,最後編寫php文件:數據庫
$sql= 「insert into biao (column_name) values」; for ($i = 0; $i < 5000000; $i++) { $sql .= "('value′),"; }; $sql = substr($sql, 0, strlen($sql) - 1); $connect_mysql->query($sql);
執行它,就能夠看到數據庫中的結果啦。blog