If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Taking MySql DB dump for selected tables.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-04-11, 10:10
Anto Vijay K J Anto Vijay K J is offline
Registered User
 
Join Date: Jul 2011
Posts: 7
Smile Taking MySql DB dump for selected tables.

Hi,

My requirement is taking MySql DB dump for particular tables in a DB using mysqldump script.My DB is running on Solaris server.

I tried following command to take db dump for single table,

mysqldump --socket=<Socket name> -u<UserName> -p<Password> <DB Name> --skip-lock-tables <TableName1> >> Test.dump

It is creating Test.dump file. But I am not sure , whether this is the correct way of taking db dump for single table.

And Please guide me to take db dump of multiple tables using single command.
Reply With Quote
  #2 (permalink)  
Old 07-05-11, 00:32
Harisankar.A Harisankar.A is offline
Registered User
 
Join Date: May 2011
Posts: 11
Taking MySql DB dump for selected tables

For taking Multiple tables dump:

-> mysqldump -u username -p -P portno --socket dbname tab1 tab2 tab3 .. > dumpfile;
Reply With Quote
  #3 (permalink)  
Old 07-05-11, 01:43
Anto Vijay K J Anto Vijay K J is offline
Registered User
 
Join Date: Jul 2011
Posts: 7
Thumbs down multiple table dump is not working

Hi HariSankar,

thanks for your reply.

I used the commad given by you, But i got the following error msg.

./mysqldump: Got error: 1146: Table 'db.tab1' doesn't exist when doing LOCK TABLES

Then I used '--skip-lock-tables' option in my command.After using this , It is creating dump file but the dump file size is always being as 1053kb.

Please give some idea about it.
Reply With Quote
  #4 (permalink)  
Old 07-05-11, 02:32
Harisankar.A Harisankar.A is offline
Registered User
 
Join Date: May 2011
Posts: 11
Hi Vijay,

In my query tab1 tab2 means your table names which you want to take dump..

Just replace the dbname with your database name and tab1 tab2 etc with your table names....
Reply With Quote
  #5 (permalink)  
Old 07-05-11, 02:51
Anto Vijay K J Anto Vijay K J is offline
Registered User
 
Join Date: Jul 2011
Posts: 7
Talking Used the same

Hi Hari,

I used the same . In the above error ,db is my DB name and tab1 is one of the table name in my db. I didnt want to mention my db name and table name , that's why mentioned like db.tab1 .
Reply With Quote
  #6 (permalink)  
Old 07-05-11, 03:17
Harisankar.A Harisankar.A is offline
Registered User
 
Join Date: May 2011
Posts: 11
> /mysqldump: Got error: 1146: Table 'db.tab1' doesn't exist when doing LOCK TABLES
It means that table is not exist in your datbase check that you provided the correct name.

.> It is creating dump file but the dump file size is always being as 1053kb.

You are worrying about size of the dumpfile.. I can't understand here..

Do you feel the dump is not taken properly?

If you want to check the dump just create the sample database and import the dump into that and check the table data....
Reply With Quote
  #7 (permalink)  
Old 07-05-11, 04:35
Anto Vijay K J Anto Vijay K J is offline
Registered User
 
Join Date: Jul 2011
Posts: 7
Unhappy

Yeah Hari,

I think it is not taking db dump properly. I tried importing the dump into the DB but it is not importing the data in the tables.
Reply With Quote
  #8 (permalink)  
Old 07-05-11, 05:01
Harisankar.A Harisankar.A is offline
Registered User
 
Join Date: May 2011
Posts: 11
Hi Vijay,

Post your dump and import statement...
Reply With Quote
  #9 (permalink)  
Old 07-05-11, 05:17
Anto Vijay K J Anto Vijay K J is offline
Registered User
 
Join Date: Jul 2011
Posts: 7
Unhappy NOn shareable

Hi Hari,

That db is being used in my client side . So i wont be able to share it .

I Used following command for importing

mysql --socket=<Socket Name> -uocm -pocm -e "source <DUMP file name>" <db name>
Reply With Quote
  #10 (permalink)  
Old 07-05-11, 05:46
Harisankar.A Harisankar.A is offline
Registered User
 
Join Date: May 2011
Posts: 11
Hi Vijay,

Use this command to import dump,

mysql -u username -p -P port --socket socketfile dbname < dump.sql
Reply With Quote
  #11 (permalink)  
Old 07-05-11, 05:59
Harisankar.A Harisankar.A is offline
Registered User
 
Join Date: May 2011
Posts: 11
You can use this also,

mysql -uocm -pocm --socket=<Socket Name> <db name> -e "source <DUMP file name>"
Reply With Quote
  #12 (permalink)  
Old 07-06-11, 00:27
Anto Vijay K J Anto Vijay K J is offline
Registered User
 
Join Date: Jul 2011
Posts: 7
Thumbs down Not working

hi Hari,

i tried the both commands , but still it is not importing the data.

I guess, dumpfile is not having data.Taking db dump is itself not proper.
Reply With Quote
  #13 (permalink)  
Old 07-06-11, 00:37
Harisankar.A Harisankar.A is offline
Registered User
 
Join Date: May 2011
Posts: 11
Hi,

Is it showing any error message while importing data?

Check whether the tables are created or not in database and open the dump file using vi editor and see whether it contains insert statement or not...
Reply With Quote
  #14 (permalink)  
Old 07-06-11, 01:32
Anto Vijay K J Anto Vijay K J is offline
Registered User
 
Join Date: Jul 2011
Posts: 7
Exclamation Dump file content

Hari,

Only below stuff is there in my dump file

Quote:
-- MySQL dump 10.9
--
-- Host: localhost Database: ocm
-- ------------------------------------------------------
-- Server version 4.1.12-standard

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0
*/;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
Reply With Quote
  #15 (permalink)  
Old 07-06-11, 01:55
Harisankar.A Harisankar.A is offline
Registered User
 
Join Date: May 2011
Posts: 11
Hi Vijay,

Check the user has a sufficient privileges for taking dump.
Try to take dump again using root user and ensure that the tables are exist in database.
If mysql dump showing any error message post it here.

ex:
mysqldump -u root -p dbname tab1 tab2 etc > dump.sql
Reply With Quote
Reply

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On