Skip to content

Instantly share code, notes, and snippets.

@mokolabs
Created August 31, 2010 22:19
Show Gist options
  • Save mokolabs/559861 to your computer and use it in GitHub Desktop.
Save mokolabs/559861 to your computer and use it in GitHub Desktop.
Getting this error when using heroku db:pull?
Mysql::Error MySQL server has gone away
The likely culprit is the default value for max_allowed_packet in MySQL on Snow
Leopard. By default this value is only 1M... buy by increasing it to 32M, you can
make this error go away.
To check the value of your max_allowed_packet size, just do this:
mysql> show variables like "%packet%";
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
1 row in set (0.00 sec)
1048576 bytes is 1 megabyte, so that's definitely too small.
Here's how to fix it:
1. FIND OR CREATE YOUR MY.CNF FILE If you installed 64bit MySQL via the mysql.com
package, just create a new my.cnf file in /etc/my.cnf. Otherwise, find your
existing my.cnf file.
2. UPDATE YOUR MAX_ALLOWED_PACKET SETTING Update the max_allowed_packet value to
32M. If you just created your my.cnf file, then just add these two lines and
save:
[mysqld]
max_allowed_packet=32M
3. RESTART MYSQL Let's restart MySQL with our new settings. You can either
restart your machine or use the handy System Preferences control panel to stop
and then restart MySQL.
4. CHECK YOUR NEW MAX_ALLOWED_PACKET SETTING
mysql> show variables like "%packet%";
+--------------------+----------+
| Variable_name | Value |
+--------------------+----------+
| max_allowed_packet | 33554432 |
+--------------------+----------+
1 row in set (0.01 sec)
Okay... perfect. max_allowed_packet is now 33554432 bytes (or 32 megabytes).
5. YOU'RE DONE!
Try running heroku db:pull again. Everything should work now. :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment