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 > How to copy a database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-15-09, 02:47
sushma007 sushma007 is offline
Registered User
 
Join Date: Aug 2007
Posts: 64
Thumbs up How to copy a database

Hi,

I have a database "DB1".
I want to copy this database, with data, as
"DB2" .

Without using MySQLdump ,is there any other command which can directly copy the Database DB1 to DB2
Reply With Quote
  #2 (permalink)  
Old 10-15-09, 06:52
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by sushma007
Without using MySQLdump ...
why would you not want to use mysqldump???
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 10-15-09, 08:36
sushma007 sushma007 is offline
Registered User
 
Join Date: Aug 2007
Posts: 64
Because it is thrweing some exceptions while dumping

Quote:
: Can't create/write to file '/root/tmp/#sql_2a27_0.MYI' (Errcode: 13) (1)
Reply With Quote
  #4 (permalink)  
Old 10-15-09, 09:47
mnirwan mnirwan is offline
Registered User
 
Join Date: Sep 2009
Posts: 64
You can do it the "hard" way ... The idea is to query INFORMATION_SCHEMA database in such a way that the resulting result is a valid SQL string that you can simply run.

I don't have a full article talking about exactly what you want ... but this one will give you pretty much the same idea: Microshell Comparing data from 2 database tables

I'd imagine you'll write queries something like this:

Code:
SELECT
	CONCAT('CREATE TABLE DB2.', TABLE_NAME, ' LIKE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') AS create_table_sql,
	CONCAT('INSERT INTO DB2.', TABLE_NAME, ' SELECT * FROM ', TABLE_SCHEMA, '.', TABLE_NAME, ';') AS populate_table_sql
FROM
	information_schema.TABLES
WHERE
	TABLE_SCHEMA = 'DB1'
;
Then once you get the result, simply copy, paste and run the SQLs.
Reply With Quote
  #5 (permalink)  
Old 10-15-09, 13:08
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,258
Quote:
Originally Posted by sushma007
Because it is thrweing some exceptions while dumping
so wither you need to get permissions to that directory, or make certain there's enough room their to write the file

OR change the location of the file to a directory that has enough room and/or you do have permissions to write to.

according to da manuel MySQL :: MySQL 5.1 Reference Manual :: 4.5.4 mysqldump ? A Database Backup Program, assuming you are running from the command line thats
Quote:
mysqldump db_name > backup-file.sql
if you are suign MySQLAdmin I'm guessing tis a setting on the relevant options page
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
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