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.
- Create and configure Carbon database.
I will be using mysql command line tool throughout the process, therefore lets login to mysql prompt like below.
~$ mysql -u <username> -p<password>
- Create a database
mysql> create database <db_name>
- Create user and grant access to the above database.
mysql>GRANT ALL ON <db_name>.* TO <user_name&[email protected]<host> IDENTIFIED BY "<password>";
- Run the mysql.sql script to configure the database. The script resides in CARBON_HOME/dbscripts/ folder.
- 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.
- Fill in the database with data.
You may use Carbon Server web console for this. Further information can be found in product documentation available in here.
- Create a backup.
- 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.
$ mysqldump -u <username> -p<password> <database_name> > backup_location/backup.sql
e.g. $ mysqldump -u root -proot regdb > /home/yumani/Documents/regdb_back.sql
- Restore the database
- 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.
- 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'
$ mysql -u <username> -p<password> <database_name>
Associate Technical Lead - Quality Assurance; WSO2, Inc.