When I was trying to import tables using a SQL file to my MySQL database, I got error saying
Got a packet bigger than 'max_allowed_packet' bytes
MariaDB [wp_rohutech]> source C:\Users\rohan.kamble\work\Projects\rohutech\sql-dump\rohutech.sql
Query OK, 0 rows affected (0.011 sec)
Query OK, 0 rows affected (0.017 sec)
Query OK, 0 rows affected (0.002 sec)
ERROR 1153 (08S01) at line 27 in file: 'C:\Users\rohan.kamble\work\Projects\rohutech\sql-dump\rohutech.sql': Got a packet bigger than 'max_allowed_packet'
bytes
ERROR 2006 (HY000) at line 247 in file: 'C:\Users\rohan.kamble\work\Projects\rohutech\sql-dump\rohutech.sql': MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 1899
Current database: wp_rohutech
Query OK, 0 rows affected (0.003 sec)
if you encounter such error you can simply increase the size of max_allowed_packet by simply passing the argument with the size you want to keep for max_allowed_packet
mysql -u root -p wp_rohutech –max_allowed_packet=1G
C:\xampp\mysql\bin>mysql -u root -p wp_rohutech --max_allowed_packet=1G
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 1912
Server version: 10.4.24-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [wp_rohutech]> source C:\Users\rohan.kamble\work\Projects\wp_rohutech\sql-dump\wp_rohutech.sql
Query OK, 0 rows affected (0.011 sec)
Query OK, 0 rows affected (0.023 sec)
Query OK, 0 rows affected (0.004 sec)
Query OK, 218 rows affected (0.042 sec)
Records: 218 Duplicates: 0 Warnings: 0
Query OK, 0 rows affected (0.000 sec)
Ref: https://dev.mysql.com/doc/refman/8.0/en/packet-too-large.html