Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2013
    Posts
    4

    Unanswered: export database to another database

    need your help ..

    can i export database to another database directly?
    and how to do it?

    thanks..

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    The only tool available for copying a database is the mysqldump utility (phpMyAdmin provides a browser front end which uses this command line tool). This takes a copy of the entire contents of a database and puts it into a file which can then be executed against the new database. The dump is simply SQL statements to create tables, stored procedures ... and INSERT statements to upload the data.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    Apr 2013
    Posts
    4
    thanks for the anwer , it helped me..
    now i have different case..
    i want to get database's contents, and import these contents into another database..
    but i want to do it without export these database contents into sql file first, i want to do it directly.. i've tried to find references from mysql documentation, but i got nothing.. would you please help me.. at least you can let me know whether i can do it or not.. thanks before..

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if the databases are on the same physical server, then you can transfer data directly from one 'database' to another 'database'.
    however you still need to create the tables in the new DB.

    assuming you have already created the tables
    Code:
    insert into MyNewDB.MyTable where select * from MyOldDB.MyTable
    however there is a risk of you screwing yup any autonumber columns. So its far safer to do as Ronan suggests in post #2
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    If you are on a Linux host, you could try using a pipe.

    Code:
    mysqldump -u old_db_username -pold_db_password --database {old_db_name} | mysql -u new_db_username -pnew_db_password -h new_db_host -D new_db_name
    This basically performs the dump and directly passes it into a mysql connection.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •