Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Copy MySQL database

  • 28-08-2007 8:44am
    #1
    Registered Users, Registered Users 2 Posts: 12,386 ✭✭✭✭


    Hey, so I have a mysql database on machine at work, i want to be able to work on it @ home too, is there an easy way of copying the database onto an external hard drive & then copy it back onto computer @ home?

    It would take too long to create all the tables again...

    Oh, and I'm not worried about the data stored in the tables, just more want to copy the full structure of db over...

    Cheers...


Comments

  • Registered Users, Registered Users 2 Posts: 2,013 ✭✭✭lynchie


    mysqldump -u <username> -p <database name> > backup.sql

    Then on machine at home..

    mysqladmin -u <username> -p create <database name>

    then mysql -u <username> -p <database name> < backup.sql


  • Closed Accounts Posts: 518 ✭✭✭danbhala


    do you have phpMyAdmin ?

    if so, its pretty easy to export the db's data & structure to a sql text file.

    *Above Post > My Post


  • Registered Users, Registered Users 2 Posts: 12,386 ✭✭✭✭dulpit


    lynchie wrote:
    mysqldump -u <username> -p <database name> > backup.sql

    Then on machine at home..

    mysqladmin -u <username> -p create <database name>

    then mysql -u <username> -p <database name> < backup.sql

    Ok, so if my username is root, password is pass, the database name is data would i do this:

    1. Open command prompt
    2. Type: mysqldump -u root -p pass data > backup.sql

    All on one line? Should I specify a place to put backup.sql? (i.e. C:\backup.sql)?

    Then do the reverse on second machine?

    1. Open command prompt
    2: Type: mysqladmin -u root -p pass create data
    3: mysql -u root -p pass data < backup.sql

    All on one line? Should I specify where backup.sql is? (i.e. F:\backup.sql)?

    Sorry for all questions, i'm rubbish at using command prompt and stuff...

    Edit: I presume this won't delete the original db, will it?


  • Registered Users, Registered Users 2 Posts: 2,013 ✭✭✭lynchie


    yup specify the full path i.e. c:\backup.sql

    No, it wont delete the source DB. mysqldump is used for creating backups of the db.

    What you have above is all fine. Type it into a command prompt window. If it doesnt work, you may not have the mysql bin directory on your path. If this is the case, make sure you add it to your path. Alternatively, download the mysql workbench and use the mysql administrator to create the backup for you.


  • Registered Users, Registered Users 2 Posts: 12,386 ✭✭✭✭dulpit


    Never realised that MySQL administrator could do that... (it's kinda obvious now that it would)

    Did a test moving from comp. to laptop @ work, worked a treat... Cheers lads!


  • Advertisement
  • Moderators, Recreation & Hobbies Moderators Posts: 4,668 Mod ✭✭✭✭Hyzepher


    I always connent remotely and copy it that way - use something like Navicat


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    are you allowed to take a database home with you?

    Most places have Data security policies that would prohibit you from doing this.


  • Registered Users, Registered Users 2 Posts: 12,386 ✭✭✭✭dulpit


    amen wrote:
    are you allowed to take a database home with you?

    Most places have Data security policies that would prohibit you from doing this.

    Working in a tiny office, i'm the only one working on this...


Advertisement