Cannot upload "to big" mysql file?

Every day solutions to every day challenges. + Brilliant stuff

Moderators: b1o, jkerr82508

Forum rules
Please feel free to post your tip it does not have to be advanced. Also ask questions directly related to the tip here. But do not start new threads with questions or ask for help here. That is what the help section is for. forum rules: http://bjoernvold.com/forum/viewtopic.php?f=8&t=568
User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Cannot upload "to big" mysql file?

Postby viking60 » 09 Oct 2013, 14:45

Often when we want to backup Mysql files we need to adjust the file sizes the server accepts for upload.
So in /etc/php/php.ini we have some max sizes to adjust
Like:
upload_max_filesize, memory_limit and post_max_size

But still I I get protests like
Got a packet bigger than 'max_allowed_packet' bytes
And that is not to be found in php.ini

For that we need to find my.cnf
in my case it is in /etc/mysql/my.cnf
And in that file you will find

Code: Select all

max_allowed_packet = 10M

increase this value and restart mysqld:

Code: Select all

sudo systemctl restart mysqld


This goes for MariaDB too.

if you have altered something in /etc/php/php.ini you may want to restart the server with

Code: Select all

sudo systemctl restart httpd


After this you should be able to upload your big mysql database.
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Cannot upload "to big" mysql file?

Postby viking60 » 23 Sep 2015, 10:40

I have found out as config and software changes that the above method is unpractical. So I use the CLI mysql aproach to import big databases now.

I download the databases from some site with phpmyadmin or adminer. Here you set if the download should create the database etc.
(There are no restriction on size when exporting a database - the problems occurs when you try to import them.)

That gives me "mydbase.sql" in my download section.

If I have chosen to let this sql create the database (during export) then I import it with this command
In my download directory:

Code: Select all

mysql -u root -p  < mydbase.sql

If I have not chosen the sql file to create the database then I need to create the database in phpmyadmin or adminer (or in the cli) first. Let us say I named it "mydatabase".

That would result in this command:

Code: Select all

mysql -u root -p mydatabase < mydbase.sql

No complaints about the size etc etc.
In the examples above my mysql user is root - it could be something else in your case. (root in mysql is not the same as Linux root :T confusing but true :-D )It is like David Cameron and Cameron Diaz - they are not related - they just share the same name :drool:


Phpmyadmin and Adminer are still fine for handling databases - but not in importing big databases - in fact they suck at it +1 They are not the only guilty party since they depend on apache and php but the result is a big headache when you try to import databases; nevertheless.

MariaDB and Mysql are the specialists there so I use them for that.

There are alternatives like Bigdump - but I have not tested it..because I don't need it.
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"


Return to “Tips & Tricks”