![]() |
|
Guide Import a Large SQL File in CyberPanel Over SSH (phpMyAdmin Stops at 2 MB) - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: CyberPanel (https://adminsforum.com/Forum-cyberpanel) +---- Forum: CyberPanel Guides & Tutorials (https://adminsforum.com/Forum-cyberpanel-guides-tutorials) +----- Forum: CyberPanel Databases & phpMyAdmin Guides (https://adminsforum.com/Forum-cyberpanel-databases-phpmyadmin-guides) +----- Thread: Guide Import a Large SQL File in CyberPanel Over SSH (phpMyAdmin Stops at 2 MB) (/Thread-guide-import-a-large-sql-file-in-cyberpanel-over-ssh-phpmyadmin-stops-at-2-mb) |
Import a Large SQL File in CyberPanel Over SSH (phpMyAdmin Stops at 2 MB) - JAY - 10-27-2026 Import a Large SQL File in CyberPanel Over SSH (phpMyAdmin Stops at 2 MB) You moved a site to CyberPanel, open phpMyAdmin, click Import, and the limit next to the file field says (Max: 2,048KiB). That's 2 MB, so almost any real database is too big, even zipped. You could raise PHP's limits, but there's a faster and more reliable way: import over SSH. We tested it on our lab server (CyberPanel 3.0, MariaDB 10.11, Ubuntu 24.04) with a 241 MB dump, and on purpose ran into the five errors people hit most, with the fix for each. phpMyAdmin's Import page on a default CyberPanel server: Why 2 MB, and why we don't just raise it CyberPanel's phpMyAdmin runs on the panel's own PHP, but it reads the same php.ini as your PHP 8.3 websites: Code: /usr/local/lsws/lsphp83/etc/php/8.3/litespeed/php.iniCode: upload_max_filesize = 2MCode: post_max_size = 8MStep 1: Create the empty database In CyberPanel: Databases > Create Database, pick the website, enter a database name, user and password. Write down the exact database and user names as List Databases shows them, in case a prefix was added. Ours: database Code: cyber_impCode: cyber_impStep 2: Get the dump onto the server Upload the Code: .sqlCode: .sql.gzCode: /home/example.com/Code: scp shop.sql.gz root@YOUR-SERVER-IP:/root/imp/Code: .gzCode: public_htmlStep 3: Import The simple way, it asks for the database user's password: Code: gunzip < shop.sql.gz | mysql -u cyber_imp -p cyber_impCode: .sqlCode: mysql -u cyber_imp -p cyber_imp < shop.sqlWhat we used, with a progress bar and the password kept out of the command line and history: Code: printf '[client]\nuser=cyber_imp\npassword=YOUR-DB-PASSWORD\n' > /root/.imp.cnf
chmod 600 /root/.imp.cnf
pv shop.sql.gz | gunzip | mysql --defaults-file=/root/.imp.cnf cyber_impCode: pvCode: apt install pvOur 241 MB test import: 241 MB, 1.5 million rows, 23 seconds. For really big imports run it inside Code: screenCode: tmuxCode: /root/.imp.cnfWhy the database user and not root? Importing as the site's own user shows the problems your site would also have later (missing rights, wrong database names) and can't touch other databases by mistake. One more catch: on CyberPanel root has its own Code: /root/.my.cnfCode: --defaults-extra-fileCode: --defaults-fileError 1: "ERROR 2006 (HY000): Server has gone away" The dump contains a single row bigger than the server allows (images or files stored in the database, big serialized options). MariaDB's default Code: max_allowed_packetServer has gone away, and the fix: To test quickly, Code: SET GLOBAL max_allowed_packet=268435456Code: printf '[mysqld]\nmax_allowed_packet = 256M\n' > /etc/mysql/mariadb.conf.d/60-import.cnf
systemctl restart mariadb
mysql -N -e 'SELECT @@max_allowed_packet'Code: --max_allowed_packet=256MCode: mysqlError 2: "Unknown collation: utf8mb4_0900_ai_ci" The dump comes from MySQL 8, CyberPanel runs MariaDB. Our MariaDB 10.11.19 didn't know MySQL 8's default collation. Replace it with one MariaDB has, in the file, before importing: Code: sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_520_ci/g' shop.sqlCode: .gzCode: gunzip < shop.sql.gz | sed 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_520_ci/g' | mysql ...Error 3: "Access denied; you need (at least one of) the SUPER, SET USER privilege(s)" The dump has views, triggers or procedures with Code: DEFINER=`olduser`@`localhost`Code: sed -E 's/DEFINER=`[^`]+`@`[^`]+`//g' shop.sql > shop-fixed.sqlError 4: "Access denied for user ... to database 'oldshop'" Some dumps start with Code: CREATE DATABASECode: USE `oldshop`Code: headCode: sed -i -E '/^(CREATE DATABASE|USE) /d' shop.sqlError 5: "Table ... already exists" A failed import stops halfway and leaves the tables it already created. Run it again and it fails on the first one. Start over with an empty database: drop and re-create it in Databases, or drop the leftover tables in phpMyAdmin, then import again. After the import
More CyberPanel guides
|