SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Michigan
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysqldump, then restore.

    Ok, I'm setting up part of my website as a DEMO, and I want it to be refreshed every so often.

    This application that I'm using uses a MYSQL database. So I'm having problem restoring the Database, when it already has tables and data.

    So I use this to dump the database:

    mysqldump --opt -h localhost -uroot -ppassword dbname > dbname.sql

    When I try to restore the DB, when there are existing tables/data, nothing changes: BTW, I use this to restore:

    mysql -h localhost -uroot -ppassword dbname < dbname.sql

    This will work if I DROP all the tables and data though.

    So I'm trying to automate all of this through a CRON JOB, and if I can work around this issue, that won't be a problem.

    So what are my options? I thought with the --opt that it would drop any existing tables and solve this, but it doesn't.

  2. #2
    SitePoint Member
    Join Date
    Jun 2004
    Location
    Big D, TX
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What version of MySQL are you running?

    I am doing the exact same thing, and it works fine for
    me. Adding --opt does a few more things as well, including
    putting locks on the tables.

    What does the error message state?

    If you do

    grep "DROP TABLE" dbname.sql

    does it give you anything back?
    Dedicated Servers - http://www.neo.net/
    24/7 support@neo.net - (800) 508-5076

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Michigan
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by NEO-Swede
    What version of MySQL are you running?

    I am doing the exact same thing, and it works fine for
    me. Adding --opt does a few more things as well, including
    putting locks on the tables.

    What does the error message state?

    If you do

    grep "DROP TABLE" dbname.sql

    does it give you anything back?
    I just figured it out. It happened to be a permission issue. Because I put -h localhost in the line, and the localhost doesn't have proper permissions, then it fails. I just removed the -h localhost, and worked like a charm!

    Thanks


Bookmarks

Posting Permissions

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