Kayako logo
Technical Chat From server configurations to local area networking - the technical discussion forum.

Kayako develops robust helpdesk software, live chat and real-time visitor monitoring software.
Kayako is trusted by more than 30,000 organizations, including a number of Fortune 500 companies and government institutions.
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  (#1) Old
Jamie Edwards Offline
Operations Manager
 
Jamie Edwards's Avatar
 
Posts: 7,676
Join Date: Jan 2006
Location: England, UK
Taking (backing up) and restoring MySQL dump files - 21-04-2007, 09:39 PM

Via SSH / MySQL CLI command interface:

Dumping a database into a file:
Code:
mysqldump -u username -ppassword databasename > dumpfilename.sql
The above command will dump the contents of databasename into a MySQL dump file named dumpfilename.sql that can later be used to drop back into a MySQL database. The username you give must be for an account that has the correct access privileges to this database.

The file will be saved relative to the location in which you executed the command. So, if you execute the command whilst in the /home/ folder, the dumpfile will be saved to /home/dumpfilename.sql.

Note: If you add the parameter "--opt", it will create the database with options to drop existing tables and data when the dump file is imported into a database.


Restoring a MySQL dump file:
Code:
mysql -u username -ppassword databasename < dumpfilename.sql
The above command will drop the contents of the dump file dumpfilename.sql into the database named databasename. Normally, tables will be overwritten using this procedure if they already exist.


Jamie Edwards (jamie.edwards ]at[ kayako.com)
----------------------------------------------------------------
---

Last edited by Jamie Edwards; 21-04-2007 at 10:37 PM.
   
Reply With Quote
  (#2) Old
bear Offline
Community Moderator
 
Posts: 747
Join Date: Jan 2005
21-04-2007, 10:35 PM

If you add one thing to that "--opt", it will create the database with options to drop existing tables and data on restore, avoiding errors and complaints from mysql.
Code:
mysqldump --opt -u ....
Also, the -p must be followed immediately by the password, no spaces. It would see the space as part of the password and reject it.
   
Reply With Quote
  (#3) Old
Jamie Edwards Offline
Operations Manager
 
Jamie Edwards's Avatar
 
Posts: 7,676
Join Date: Jan 2006
Location: England, UK
21-04-2007, 10:37 PM

Thanks for the suggestion, updated!


Jamie Edwards (jamie.edwards ]at[ kayako.com)
----------------------------------------------------------------
---
   
Reply With Quote
Reply

Tags
backing, dump, files, mysql, restoring

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78