MyBB Community Forums

Full Version: Backing up and Restoring Databases
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
I've noticed a lot of questions on how to backup and restore databases. This thread should help everyone.

There are two ways to backup your database, phpMyAdmin or SSH.

Backing up your database using phpMyAdmin

1. Login to phpMyAdmin and select the database you wish to dump

2. Click on the �Export� tab at the top of the page

3. Click �Select All� below the list of tables

4. Make the format is SQL

5. Click �Save as File� to download the result, or leave this box unticked to view it on-screen

6. Ensure that both �Structure� and �Data� are ticked

7. Choose a compression type, if any, from the bottom of the form

8. Click �Go�

Backing up your database using SSH

Not all hosting accounts have this, you'll have to ask your host if you have SSH access.

1. Log into your SSH account.

2. Type mysqldump --opt -Q -uUSERNAME -p DATABASENAME > /PATH/TO/DUMP.SQL

USERNAME � this is the username you use to access MySQL. You can find it out by looking in inc/config.php

DATABASENAME � the name of the database that MyBB is installed on.

/PATH/TO/DUMP.SQL � this is the path to the file that will be stored. If you don't know where to put it, use mybb_backup.sql or something like that.
Restoring a backup with phpMyAdmin

1. To restore a database, you click the SQL tab.
2. On the "SQL"-page , unclick the show query here again.
3. Browse to your backup of the database.
4. Click Go.

Restoring a backup with SSH

mysql -uUSERNAME -p DBNAME < /PATH/TO/DUMP.SQL

USERNAME - this username which you use to access MySQL.

DBNAME - the name of the database used for MyBB.

/PATH/TO/DUMP.SQL - this is the path to the backup file that you have on the server. You will have to upload it to the server since you used phpMyAdmin to back it up.

Don't have SSH?

If you don't have SSH access, you can download a restoring tool called BigDump. I've used it many times and it's always worked. The biggest database i've restored with it was 2 GB.

Getting an error when restoring?

No matter how you try to restore your database, you need to make sure all the tables are deleted (or dropped) before you go to restore it, otherwise you'll end up getting an error like "Table 'mybb_adminlog' already exists".
I think it should be noted that most shared servers have a maximum upload limit for PHP.
You can find this value by looking at the PHP Info panel in the Admin CP. Then look for the value upload_max_filesize. If your backup file is larger than this, then you may have trouble using PHPMyAdmin to restore your database. In this case, your only other option might be to use SSH.
Your host should be able to restore a database for you even if they don't provide SSH to you. Just email them and ask them. If they won't restore your database then change hosts Smile
You can break up the SQL file and do it in parts. Alas that takes time.
i think that in general admin must can backup his forum by a command quickly!
i mean that in admin cp we can have a page or subpage(a parameter to db maintaining page) that make backup from all of forums!
To restore your backed up database you can also use bigdump

http://www.ozerov.de/bigdump.php
imei Wrote:i think that in general admin must can backup his forum by a command quickly!
i mean that in admin cp we can have a page or subpage(a parameter to db maintaining page) that make backup from all of forums!

You may be interested to know then that there is a module in development which allows you to backup your forum database or restore a previously made backup directly from your admin cp.

More information on this module (and others) will be posted over the coming weeks. Smile
Do you have some more info, now?
decswxaqz Wrote:I think it should be noted that most shared servers have a maximum upload limit for PHP.
You can find this value by looking at the PHP Info panel in the Admin CP. Then look for the value upload_max_filesize. If your backup file is larger than this, then you may have trouble using PHPMyAdmin to restore your database. In this case, your only other option might be to use SSH.
Smile


PHP.ini
Certain php variables such as register_globals are defined by default on the server php.ini.

You can overwrite global php settings by creating your own php.ini file, defining these settings within the file, chmoding the file to 755 and placing it within the executing scripts directory.

Copy the text below and save the file as php.ini, and upload it to the root and forum directories...... chmod to 755.

; Maximum allowed size for uploaded files.
upload_max_filesize = 8M


That's about the maximum limit for "Globals"... but it also won't show up in the Admin CP as 8Mb, it will still be 2.-something. Toungue
Pages: 1 2 3 4 5