Datareign

This is the replacement for saving and restoring databases or single tables.

To save a single table…

/Applications/XAMPP/xamppfiles/bin/mysqldump \
-u root -p \
--single-transaction SalesDatabase \
--tables SalesPeopleTable \
>/Data/GlobalData/Projects/Sales/SalesPeopleTable.sql

We've broken this up into lines for clarity but you would probably enter it as a single line in most cases.

The output is a file of SQL that can re-create the table(s) or database simply by piping it into the mysql command line…

/Applications/XAMPP/xamppfiles/bin/mysql \
-u root -p \
SalesDatabase \
</Data/GlobalData/Projects/Sales/SalesPeopleTable.sql 

If you get an error of the form: ERROR 1153 (08S01) at line 1958: Got a packet bigger than 'max_allowed_packet' bytes when loading a database, you can try the following:

1. Connect to the database and issue the following commands…

mysql> set global max_allowed_packet=1000000000; 
Query OK, 0 rows affected (0.00 sec)
   
mysql> set global net_buffer_length=1000000;
Query OK, 0 rows affected (0.00 sec)

(the values need to be big enough to comfortably exceed the size of your incoming file)

2. With the above session still open, restart the import. This should enable you to bring the entire database/table into the DBMS.

If you need to permanently fix this, alter the value max_allowed_packet in my.cnf to a suitably large number (100M is usually enough for any upload).

Last modified: 2009/11/06 15:07