To restore a database to your forum, you will first need to know what database engine your forum is using in order to determine which instructions to follow. MyBB supports the following database engines:
-
MySQL (In this demonstration, PhpMyAdmin will be used)
-
SQLite (In this demonstration, PhpLiteAdmin will be used)
-
PostgreSQL (In this demonstration, PhpPgAdmin will be used)
In the following instructions Linux CentOS 7 will be used, so commands may differ.
MySQL Database Restore
- Once logged into PhpMyAdmin, select your database from the side-menu on the left.
- From here, select “Import” from the top menu. You will be presented with a page like this:
-
Select “Choose File”, browse to your backup, and click “Open” on the Windows Prompt.
-
Generally, the settings on this page can be left as is, but you may alter where appropriate.
-
Click “Go”. If successful, a message saying so will be presented as well as your tables in the side-menu on the left.
SQLite Database Restore
- Login to PhpLiteAdmin and select your database from the side-menu on the left.
- Select “Import” from the top menu and you will be presented with a page like this:
-
Select “Choose File”, browse to your backup, and click “Open” on the Windows Prompt.
-
Generally, the settings on this page can be left as is, but you may alter where appropriate.
-
Click “Import”. If successful, you will see your tables in the side-menu on the left, as well as a message letting you know the import was successful.
PostgreSQL Database Restore
- Login to PhpPgAdmin and select your database from the side-menu on the left.
- Select “SQL” from the top menu and you will be presented with a page like this:
-
Select “Choose File”, browse to your backup, and click “Open” on the Windows Prompt.
-
Click “Execute”. Allow the SQL to run. If successful, you will be able to scroll down to the bottom of the page and it will look something like this:
Database Restore using SSH
MySQL
- After logging into your server via SSH, run the following:
mysql -u YOUR_MYBB_DB_USER -p YOUR_MYBB_DBNAME < /PATH/TO/DUMP.SQL
- You will be prompted for your password. If successful, your SSH window will look something like this:
- To be sure, log back into MySQL by running the following (When prompted, enter password):
mysql -u YOUR_MYBB_DB_USER -p
- Now run the following to select your database and show existing tables:
USE database_name_here; SHOW TABLES;
- If successful, your SSH window will look something like this:
SQLite
- After logging into your server via SSH, run the following to import your database:
sqlite3 database_name < /PATH/TO/DUMP.SQL
- Now login to your database and check to see if your tables exist by running the following:
sqlite3 database_name.db
- Once you have entered SQLite, you will be greeted with a simlar message to the following:
- Proceed to run the following:
.tables
- Your SSH window should now look something like this:
PostgreSQL
- After logging into your server via SSH, you will now need to enter PostgreSQL. Your method may slightly differ when logging in. Run the following to login:
su - postgres
- To restore your database, you will need to run the following:
psql database_name < /PATH/TO/DUMP.SQL
- You can now proceed to run the following to output your tables:
psql database_name
- Followed by:
\dt
Optional
- Now that you have restored your database, we are not quite done yet. You may now need to configure your database settings in
./inc/config.php
:
$config['database']['table_prefix'] = 'mybb_'; - The Table Prefix from the database should be placed here.
Note: If you are restoring a database from IcyBoards, you will need to replace your current prefix in ./inc/config.php
with your new prefix (in PhpMyAdmin). Additionally, you will need correct the Uploads Path
and Avatar Upload Path
in the Admin CP:
Uploads Path - By default, MyBB's Upload Path is ./uploads
Avatar Upload Path - By default, MyBB's Avatar Upload Path is ./uploads/avatars