Skip to content

Instantly share code, notes, and snippets.

View slava-konashkov's full-sized avatar
🏠
Working from home

Viacheslav Konashkov slava-konashkov

🏠
Working from home
View GitHub Profile
@slava-konashkov
slava-konashkov / gist:3e1292caa321c1d4be7bd8c537143930
Created April 29, 2022 09:33
PHP: Import huge SQL file to MySQL
$mysqli = new mysqli('localhost', '#username', '#password', '#database');
$handle = fopen('sqldump.sql', 'rb');
if ($handle) {
while (!feof($handle)) {
// This assumes you don't have a row that is > 1MB (1000000)
// which is unlikely given the size of your DB
// Note that it has a DIRECT effect on your scripts memory
// usage.
$buffer = stream_get_line($handle, 1000000, ";\n");