|
There are few things more frustrating than exporting your MySQL data frequently, only to find that you get an error message when you try to import the SQL script. Avoid painful errors like this one: ERROR 1044: Access denied for user: '@127.0.0.1' to database 'mysql'
EXPORTING PROPERLY WHEN YOU HAVE NO CREATE DATABASE PRIVILEGES
When you login to the phpMyAdmin interface for your mysql server and click "export", you're taken to the export configuration screen. This is a full database export and the resulting sql script will always attempt to "CREATE DATABASE", whether you have "Add DROP DATABASE" checked or not.
To avoid this issue you should instead choose the database you want to backup from the select list in the left frame, then click the export tab you see on the right frame. Click "select all" under the tables list in the left portion of the right frame to mark everything in that db for export.
The other default settings will work if you are aggregating disparate data from two sources, but you'll end up with duplicate data if you run an import on the same script more than once. Since I like to keep my various MySql servers in sync, I always check the "Add DROP TABLE" and "Add IF NOT EXISTS" options.
The first option will make sure you end up with an exact copy of the original database export on the server you're importing to. The second option ensures that you won't throw any errors if you're importing to an existing database with the tables already defined. If you don't check this option you have to manually drop all the tables on the destination database prior to running the import script.
It would be appropriate to leave these unchecked if you have other stuff in the destination database that you don't want to lose. An example might be two different MySQL servers with similar data models, that run two different sites. You might want to only add the unique stuff from db1 to db2. |