The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to restore MySQL data/setup?

Discussion in 'General Discussion' started by Wallaby, Nov 30, 2003.

  1. Wallaby

    Wallaby Well-Known Member

    Joined:
    Aug 15, 2001
    Messages:
    131
    Likes Received:
    1
    Trophy Points:
    18
    I'm looking for some advice restoring the MySQL setup and databases from a backup after a total operating system restore (following a file system corruption).

    OS is RedHat 9 (original was 7.3 though). MySQL is 4.x, as the original was.

    Here's what I have from a backup (not a CPanel backup, done by another backup script):

    1) An .sql dump file for each "user" database.

    2) A mysql.sql dump file with what looks like the "system" database, user etc info.

    3) A database.sql dump file containing only:

    -- MySQL dump 9.09
    --
    -- Host: localhost Database: Database
    ---------------------------------------------------------
    -- Server version 4.0.15-standard

    My questions are:

    a) How best to go about restoring the MySQL system info and databases without danger of a screwup.

    b) What order should I restore things in? "User" data first, or the mysql.sql?

    c) Do I need the database.sql file?

    I'm ok with how to import a dump file using:

    mysql -uUSERNAME -pPASSWORD newdbname < /path/to/dump.sql

    but AFAIK the database must have been created first?

    Any advice very welcome!
     
  2. Wallaby

    Wallaby Well-Known Member

    Joined:
    Aug 15, 2001
    Messages:
    131
    Likes Received:
    1
    Trophy Points:
    18
    No pearls of wisdom then? ;)

    If anyone's interested, here's what I did:

    1. Created a new databse called newmysql.

    2. Imported the sql dump file mysql.sql into this database:

    mysql -uUSERNAME -pPASSWORD newmysql < /path/to/mysql.sql

    3. Stopped mysql, then copied the (newly created) files from the newmysql database directory into the /var/lib/mysql/mysql directory.

    4. Restarted mysql.

    This got me the usernames and passwords back.

    For the individual databases I created each one (mysql at the shell prompt and then CREATE DATABASE databasename; ). Then imported the dump file using the command in 2 above with the relevant database name etc.

    This seems to have worked fine. There is probably a much easier way, but the job got done.
     
Loading...

Share This Page