Importing large databases in MySQL

by Armand Niculescu Email
  • Currently 2.85/5
  • 1
  • 2
  • 3
  • 4
  • 5
  • i

One of the things I like about PhpMyAdmin is its ability to export an entire database as a series of SQL statements (CREATE and INSERT), a feature I miss in SQL Server.

On the other hand the same PhpMyAdmin has a very serious limitation when it comes to import back SQL files: it wouldn’t import any files larger than 2Mb. I’m not sure what are the technical reasons for this limitation. This is due to the PHP configuration (upload_max_filesize and post_max_filesize directives in PHP.ini). If you are using a sared server, you may not be able to change these values.

Fortunately I’ve discovered a very simple tool called BigDump. This little PHP script allows for arbitrary-sized sql files to be imported in the MySql database with no headaches. It’s pretty simple to configure, files can be uploaded via ftp and it’ll show them in a list for easy restore. It supports both text (*.sql) and compressed (*.gz) files.

Update: As Joe Limonada (hi Ami :) ) has said, if you have access to the shell, you can write


mysqldump -u MYSQL_USERNAME -p -h MYSQL_SERVER_ADDRESS DATABASE_NAME > dump.sql

to backup the database and


mysql -u MYSQL_USERNAME -p -h MYSQL_SERVER_ADDRESS DATABASE_NAME < dump.sql

to restore.

Tags: mysql, php, restore, sql

2 comments

Comment from: SchizoDuckie [Visitor] Email · http://www.schizofreend.nl
This is NOT PhpMyAdmin's fault. It's due to your own php configuration that has its limits on max upload filesize and probably max execution time too.

28 May 07 @ 16:18
Comment from: Joe Limonada [Visitor] Email
In some situation you can use someting like this:
Unix systems: cat dumpfile | mysql -u ...
Windows: type dumpfile | mysql -u ...

There should not be a 2Mb or 2Gb limit from the system since it uses pipelines.
05 Jun 07 @ 21:56

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

This is the blog of the Media Division team. We're giving back to the community some of the things we have learned while building all sorts of apps. Concentrating on Flash/Actionscript, we'll also cover C#, MSSQL, ColdFusion/Oracle and areas like Photography and design. We're writing original articles only - no silly stuff to generate more traffic.

Search

XML Feeds

Aggregated by MXNA

Aggregated by MXNA

Related Links