Migrating from MySQL to MS SQL Server
Exchange Reporter Plus, from build 4142 and above, comes bundled with a PostgreSQL database to store reporting, monitoring, and auditing data. But the builds below 4142 had a MySQL database for this purpose. Exchange Reporter Plus supports MS SQL Server and enables you to migrate from the built-in PostgreSQL or MySQL database to an MS SQL database. This page will walk you through the MySQL to MS SQL database migration process.
Supported versions of MS SQL: SQL Server 2008 R2, SQL Server 2012, SQL Server 2014, SQL Server 2016, and SQL Server 2017
Prerequisites for the migration process
In the MS SQL server used for migration, make sure that the following conditions are satisfied:
- The SQL Server Browser service is up and running.
- TCP/IP is enabled for SQL Server Network Configuration.
- All client protocols are enabled.
- MS SQL Server access is delegated to a user with sysadmin and db_owner permissions at the server and database levels, respectively.
Refer to Appendix A for information on configuring prerequisites 1, 2, and 3. Refer to Appendix B for help configuring prerequisite 4.
Migrating from MySQL to MS SQL
Migrating data from Exchange Reporter Plus’ MySQL database to MS SQL consists of the following steps:
- Backing up the Exchange Reporter Plus database
- Migrating MySQL data to MS SQL
Step 1: Backing up the Exchange Reporter Plus database
Note: This step is not required if you are migrating the database of a freshly installed Exchange Reporter Plus instance.
- Stop Exchange Reporter Plus. (Note: This is essential before performing the backup.)
- If Exchange Reporter Plus is running as an application, click the Windows icon. Search for Exchange Reporter Plus and choose Stop Exchange Reporter Plus.
- If Exchange Reporter Plus is running as a service, click the Windows icon. Search for Services. In the window that appears, choose ManageEngine Exchange Reporter Plus and select Stop the service on the left side.
- Navigate to <Exchange Reporter Plus installation directory>\bin.
Note: By default, Exchange Reporter Plus is installed at C:\Program Files\ManageEngine\Exchange Reporter Plus.
- Run backupDB.bat (Windows batch file) as an administrator. Do not terminate the process until it is finished.
- Data in the default database of Exchange Reporter Plus will be backed up and stored under Exchange Reporter Plus installation directory>\backup\OfflineBackup_<Backup Time>.
Note: If the below error shows up while running the backupDB file, double-check that the product has been stopped before proceeding.
Step 2: Migrating MySQL data to MS SQL
- If MS SQL Server is installed on a remote computer, install the necessary command line utilities and native clients as per the SQL Server version and CPU type of the machine where Exchange Reporter Plus is installed, then proceed to the next step.
- Copy the following files to <Exchange Reporter Plus installation directory>\bin:
- bcp.exe: <MSSQL installation directory>\Tools\Binn\bcp.exe
- bcp.rll: <MSSQL installation directory>\Tools\Binn\Resources\1033\bcp.rll
- Stop Exchange Reporter Plus. (Note: This is essential before performing the migration.)
- If Exchange Reporter Plus is running as an application, click the Windows icon. Search for Exchange Reporter Plus and choose Stop Exchange Reporter Plus.
- If Exchange Reporter Plus is running as a service, click the Windows icon. Search for Services. In the window that appears, choose ManageEngine Exchange Reporter Plus and select Stop the service on the left side.
- Navigate to <Exchange Reporter Plus installation directory>\bin.
- Run ChangeDB (Windows batch file) as an administrator. In the Database Setup Wizard that appears, select MS SQL Server as the Server Type.
- Enter the Host Name, Database Name, and Port number of MS SQL Server.
Note: If you want to enable SSL Connection to secure the MS SQL migration, then make sure you have followed all the steps given in this guide.
- Select Yes beside Migrate Data to migrate with data intact. This makes a copy of all the data (e.g., previously generated reports) in the MS SQL database to which you are migrating. If you'd like a fresh installation with no data in place after migration, choose No.
Note: Data will remain in the default MySQL database even after the migration regardless of the option you choose. However, only the MS SQL database will be active and used.
- Select the SQL Server instance from the list of available instances.
- Select the Authentication type.
- If you choose Windows Authentication, provide the Domain Name, User Name, and Password of the service account that has necessary permission to access the MS SQL server.
- If you choose SQL Server Authentication, provide the User Name and Password of the user who has access to the MS SQL server.
- Click Test Connection to check the status. If the connection fails, try reentering the correct credentials and establishing the connection again.
- Click Save.
- Start the Exchange Reporter Plus server or service to work with MS SQL Server as the database.
Appendix A
Configuring MS SQL Server
Note: If you already have a functional MS SQL Server instance, then this step is not required. Follow the steps below to configure a freshly installed MS SQL Server instance:
- Open SQL Server Configuration Manager. (You can also run compmgmt.msc in the Command Prompt.)
- Go to SQL Server Services → SQL Server Browser. Make sure the SQL Server Browser is running.
- Go to SQL Server Network Configuration and double-click Protocols for <Instance _Name>.
- Click the TCP/IP protocol and enable it.
- Restart the SQL Server service for the changes to take effect.
Note: SQLEXPRESS is the instance name provided while configuring MS SQL Server in general; however, it can be changed. SQLEXPRESS will be used hereafter in this document.
- Go back to SQL Server Configuration Manager. In the left pane:
- Navigate to SQL Server Network Configuration → Protocols for SQLEXPRESS, and enable all the protocols.
- Navigate to SQL Native Client Configuration → Client Protocols, and enable all the protocols.
Appendix B
Delegating MS SQL Server access to users
It is necessary to add a login for users to access the configured MS SQL Server instance either using Windows Authentication or SQL Server Authentication. It is not mandatory to create a new login. You can use existing service accounts, too. If there are none, then follow the steps below to create a new login and equip the user with the necessary permissions.
- Log in to SQL Server Management Studio.
- In the left pane, navigate to Machine Name → SQLEXPRESS → Security → Logins.
- Right-click Logins and select New Login.
- Provide a Login Name and choose whether to use Windows Authentication or SQL Server Authentication.
- If you choose Windows Authentication, enter the Windows NT name of the user to whom access must be granted.
- If you choose SQL Server Authentication, you will be prompted to create a new user by entering a User Name and Password.
- The new user must have the sysadmin role at the server level and the db_owner role at the database level. Follow these steps to provide the sysadmin and db_owner role permissions:
- Navigate to Machine Name → SQLEXPRESS → Security → Logins. Right-click the user, then select Properties.
- Go to Server Roles, check the box next to sysadmin, and click OK.
- Go to User Mapping in the left pane. In the Users mapped to this login list, check your preferred database. In the Database role membership for list, select db_owner. Click OK.
Note: For details about user roles, refer to the documents in the following links:
For server-level roles: http://msdn.microsoft.com/en-us/library/ms188659.aspx
For database-level roles: http://msdn.microsoft.com/en-us/library/ms189121.aspx
In general, the configured account needs db_owner privileges to complete the migration process successfully. If you would like to go with more granular roles, you can opt for db_datareader, db_datawriter, db_ddladmin, or db_backupoperator permissions or, as the last choice, go for the db_ddladmin set 3 permissions listed below.
Set |
Required database role |
Required permissions |
Set 1 |
db_owner |
Not required |
Set 2 |
db_datareader, db_datawriter, db_ddladmin, db_backupoperator |
Not required |
Set 3 |
db_ddladmin |
ALTER ANY TABLE, ALTER ANY AGGREGATE, ALTER ANY DEFAULT, ALTER ANY FUNCTION, ALTER ANY PROCEDURE, ALTER ANY QUEUE, ALTER ANY RULE, ALTER ANY SYNONYM, ALTER ANY TYPE, ALTER ANY VIEW, ALTER ANY XML SCHEMA COLLECTION, ALTER ANY REFERENCES, CONTROL ON CERTIFICATE::[ZOHO_CERT] TO [user], CONTROL ON SYMMETRIC KEY::[##MS_DatabaseMasterKey##] TO [user], CONTROL ON SYMMETRIC KEY::[ZOHO_SYMM_KEY] TO [user] |
Important: Please note that you must have the db_owner permission while migrating MySQL to MS SQL for the first time. After a successful migration, you can revoke the db_owner permission for the account and provide Set 2 or Set 3 permissions.