Creating a WSO2 Carbon Database Dump and Restoring - MySQL 5.1

  • By Yumani Ranaweera
  • 3 May, 2012


In this guide I will be showing you how to create a WSO2 Carbon data dump in MySQL 5.1 and how to restore it.

  1. Create and configure Carbon database.
  2. I will be using mysql command line tool throughout the process, therefore lets login to mysql prompt like below.

    ~$ mysql -u &ltusername&gt -p&ltpassword&gt

    1. Create a database
    2. mysql> create database &ltdb_name>
    3. Create user and grant access to the above database.
    4. mysql>GRANT ALL ON &ltdb_name&gt.* TO &ltuser_name&[email protected]&lthost&gt IDENTIFIED BY "&ltpassword&gt";
    5. Run the mysql.sql script to configure the database. The script resides in CARBON_HOME/dbscripts/ folder.
    6. mysql>use &ltdb_name>
      mysql>source mysql.sql;
    7. Next copy the database driver to CARBON_HOME\repository\components\lib and point the configuration files (usermgmt.xml, registry.xml) to the database and start the Carbon server.

  3. Fill in the database with data.
  4. You may use Carbon Server web console for this. Further information can be found in product documentation available in here.


  5. Create a backup.
    1. Create a backup of the database by issuing the following command in command prompt. In the above example, 'regdb' database will be backed-up in 'regdb_back.sql' file. The dump will be created in the place where you are executing the command from.
    2. $ mysqldump -u &ltusername&gt -p&ltpassword&gt &ltdatabase_name&gt > backup_location/backup.sql
       e.g. $ mysqldump -u root -proot regdb > /home/yumani/Documents/regdb_back.sql


  6. Restore the database
    1. To restore the database from the above dump you must first clean the previous environment. Login to mysql and drop previous user and the database and recreate them. Remember to grant same permission to the user.
    2. After the schema is cleaned, import the backup using the following command. In the example that I've given below, 'regdb' database will be restored using 'regdb_back.sql'
    3. $ mysql -u &ltusername&gt -p&ltpassword&gt &ltdatabase_name&gt 




Yumani Ranaweera

Associate Technical Lead - Quality Assurance; WSO2, Inc.

[email protected]