Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Aug 2008
    Location
    India
    Posts
    211

    Red face fastest way to restore 5gb db

    hello i am trying to restore an account with a mysql of 5+gb all sites are going down while this happens i max waited 6 hours to see cpanel still restoring that sql file, any fast way to restore it ? i have old server root login can we do some copy paste that sql folder or any way

  2. #2
    Member Miraenda's Avatar
    Join Date
    Jul 2004
    Location
    Coralville, Iowa USA
    Posts
    244

    Default

    There's a fast way and a better way. The better way is to use mysqldump to get the database:

    Code:
    mysqldump -u username -ppassword database_name > FILE.sql
    If you run this as the root user in root SSH, you can take out the -u username and -ppassword fields and just use:

    Code:
    mysqldump database_name > FILE.sql
    Let's say the username is myuser with database name dbtest and you want to save the file as myuser_dbtest.sql, you'd do:

    Code:
    mysqldump myuser_dbtest > myuser_dbtest.sql
    You can then restore this database on the new machine with this command (again as root user running it to avoid the username and password details being needed):

    Code:
    mysql database_name < FILE.sql
    As from my prior example, it would be the following:

    Code:
    mysql myuser_dbtest < myuser_dbtest.sql
    If your file isn't in the location you are at, the path to the file must be provided so /home/myuser_dbtest.sql if you placed it into /home or whatever location.

    Of note, the database must already exist to import it this way. If the database does not exist, please create it in the user's cPanel first.

    Now, a faster way would be just to copy /var/lib/mysql/user_dbname folder and files to the new machine. The issue with doing this is that if the database is active, it could corrupt. Also, this will very likely corrupt if it has any InnoDB tables as they share the data into the /var/lib/mysql/ibdata1 file, so you can't just copy /var/lib/mysql/user_dbname folders like that (you must do a dump file to get the database instead).

    To see which databases have InnoDB tables, you can run this command in mysql CLI (simply enter mysql in root SSH to go into MySQL CLI):

    Code:
    select TABLE_SCHEMA, table_name FROM INFORMATION_SCHEMA.tables where table_type='BASE TABLE' and engine = 'InnoDB';
    This will output details like the following to show databases with InnoDB tables (this example is on my machine):

    Code:
    +---------------+-------------------+
    | TABLE_SCHEMA  | table_name        |
    +---------------+-------------------+
    | roundcube     | cache             | 
    | roundcube     | contacts          | 
    | roundcube     | identities        | 
    | roundcube     | messages          | 
    | roundcube     | session           | 
    | roundcube     | users             | 
    +---------------+-------------------+
    6 rows in set (0.06 sec)
    Last edited by Miraenda; 07-02-2010 at 01:08 PM.

  3. #3
    Registered User
    Join Date
    Feb 2007
    Posts
    4

    Default

    you can use mysqlhotcopy or illegal copy for /var/lib/mysql/databasename/ content
    Thank you

  4. #4
    Member
    Join Date
    Aug 2008
    Location
    India
    Posts
    211

    Cool

    thanks guys you guys helped a lot , i did copy files and it worked

Similar Threads & Tags
Similar threads

  1. Fastest way to recover from a crash?
    By rightguy in forum Data Protection
    Replies: 4
    Last Post: 07-23-2009, 10:16 PM
  2. Fastest Way to move Accounts
    By binaer in forum cPanel and WHM Discussions
    Replies: 16
    Last Post: 12-08-2005, 11:21 PM
  3. Fastest way to get clients?
    By dev.null in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 11-20-2003, 12:31 PM
  4. What is the most and fastest updated Skin?
    By First Faze in forum Themes and Branding
    Replies: 2
    Last Post: 05-12-2002, 01:08 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube