Many things change when you change the database, including your business and technical infrastructure. The primary reasons for database migration, for instance MariaDB to SQL server, are improved performance, adoption of a more reliable and secure platform, modernization of the DBMS, and cost-cutting.

Any database migration process has both advantages and disadvantages. The major challenges are the complexity of the source data, data corruption, infrastructure compatibility, and security. As a result, data migration strategies must be effective, reversible, fail-safe, auditable, and secure.

Read this blog to learn how to migrate MariaDB to SQL Server if you want to get analytics-ready data quickly and easily.

How to Migrate Data from MariaDB to SQL Server?

There are several methods for transferring data from MariaDB to SQL Server:

  • Using Hevo Data
  • Making Use of a Dump (Structure)
  • Making Use of a Dump (Data)
  • Making Use of a CSV File
  • CONNECT Tables in Action
  • Linked Server

If the tables do not exist in SQL Server at all, we must first generate a dump. The dump may or may not contain data.

If the tables are already in SQL Server, we can move the rows using CSV files rather than dumps. CSV files are the most compact format for transferring data between technologies.

Another option for moving data with tables already in SQL Server is to insert the rows into CONNECT tables that “point” to remote SQL Server tables.

1) Using Hevo Data

Using Hevo’s no-code and automated Data Pipeline, you can migrate MariaDB to SQL Server. Hevo is the only real-time ELT No-code Data Pipeline platform that cost-effectively automates data pipelines that are flexible to your needs. 

With integration with 150+ Data Sources (40+ free sources), we help you not only export data from sources & load data to destinations like Data Warehouse but also transform & enrich your data, & make it analysis-ready.

Get started for Free with Hevo!

In the first step, you’ll need to set up MySQL Binary Logs for replication. Input the following commands to check of BinLog replication is already enabled.

Step 1: Open a secure MariaDB shell

mysql -u username -p

Step 2: Enter the user’s password and the run the following command:

select @@log_bin;

If the command returns 1, BinLog replication is enabled. If it returns 0, you’ll need to enable it.

Follow the following steps to enable BinLog replication:

  • Log in to your MariaDB server and view the configuration
sudo nano etc/mysql/mariadb.conf.d/50-server.cnf
  • Add the following configurations if they aren’t added already
 [mysqld]
 binlog_format=ROW
 binlog_row_image=FULL
 server-id=1
 expire_logs_days=3
 log_bin=/var/log/mysql/mysql-bin.log)
 log_slave_updates=1
 max_binlog_size = 100M
  • Run the following command to restart your MariaDB instance
 sudo service mysql restart
  • Log in to MariaDB server to check the BinLog configuration again after restarting
 SELECT @@log_bin;

You’ll see that the value returned is 1, which means BinLog replication is now enabled.

Step 3: Whitelist Hevo’s IP addresses

  • Enter the MariaDB server configuration
sudo vim etc/mysql/mariadb.conf.d/50-server.cnf
  • Scroll to [mysqld] and add any one of the following commands
 bind-address = 0.0.0.0
 bind-address = 10.2.7.152

Next, you must check Hevo’s IP addresses for your region and then save the file.

Step 4: Finally, before setting up Hevo’s pipeline to replicate MariaDB data to SQL Server, follow these steps to grant user privileges.

  • Go to MariaDB MySQL server
 mysql -u root -p
  • Next, grant SELECT privileges to the user
 GRANT SELECT ON *.* to jacob@localhost;
  • In the next step, which is optional, you can view the grants for the user
 show grants for jacob@localhost;

Step 5: Set up source and destination in Hevo’s pipeline to replicate data in minutes

Configure MariaDB as the source

mariadb to sql server: configure source
Image Source

Configure MySQL Server as the destination

mariadb to sql server: configure destination
Image Source

Test your connection, and that’s it. Hevo will ensure that your MariaDB database is migrated to SQL Server seamlessly. And, our support is available around the clock for any help.

2) Making Use of a Dump (Structure)

mysqldump can create dumps of all databases, a single database, or a set of tables. By using the WHERE clause, you can even dump only a subset of the rows.

We can dump the table structures without data by specifying the —no-data option.

—compatible=mssql will generate output that should work in SQL Server.

Limitations of Using Dump (Structure) to migrate Mariadb to SQL Server

  • Data Integrity: Data inconsistencies can occur in the exported SQL dump if there is any activity on the source database during the dump process. You can avoid this by putting the database in read-only mode or locking tables.  But it can further impact application availability.
  • Memory Limitations:  There might be memory constraints if you’re importing a massive SQL dump file. This may require adjusting the MySQL server configurations on the destination machine.

3) Making Use of a Dump (Data)

By default, mysqldump generates output that includes both data and structure.

To avoid the CREATE TABLE statements, use —no-create-info.

—compatible=mssql will generate output that should work in SQL Server.

—single-transaction should be used to select the source data in a single transaction, resulting in a consistent dump.

When dumping large tables, it quickly speeds up the dump process.

Limitations of Using Dump (Data) 

  • Security Issues: Data dumps contain all table data which also includes potentially sensitive information. This might require extra care for secure storage and handling. Also, Dump files have no inherent access control, necessitating manual configuration of user permissions in the target database.
  • Limited Functionality: Data dumps do not include stored procedures and functions, requiring separate migration strategies or manual recreation in SQL Server. Further, they offer limited ability to customize the migration process or filter specific data subsets.

4) Making Use of a CSV File

Data can also be exported from MariaDB to SQL Server using CSV files. There are several methods for generating CSV files from MariaDB:

  • The statement SELECT INTO OUTFILE.
  • The CONNECT storage engine’s CSV table type.
  • The CSV storage engine (note that NULL and indexes are not supported).

These are the simple 3 methods to export data from MariaDB to SQL Server.

Limitations of Using CSV files for MariaDB to SQL Server migration 

  • Limited Data Types: CSV files can only handle simple data. Images or other complex data cannot be saved in a CSV file.  Also, there is no standard way to represent binary data in CSV files, and they give limited support to special characters. 
  • Customization Issues: They have limited ability to customize the migration process, filter specific data subsets, or handle complex data relationships.

5) CONNECT Tables in Action

The CONNECT storage engine enables access to external data in a variety of formats:

  • Files containing data (CSV, JSON, XML, HTML and more).
  • Remote databases can be accessed via the ODBC or JDBC standards, or via the MariaDB/MySQL native protocol.
  • Some unique data sources.
  • CONNECT was previously mentioned because it can read a CSV file and query it in SQL, filtering and transforming the data that we want to move into regular MariaDB tables.

CONNECT, on the other hand, can connect to remote SQL Server tables. We can read and even write data to it. To make CONNECT work with MariaDB to SQL Server, we must meet the following requirements:

  • Install the ODBC driver, which is available from the Microsoft website. Linux and macOS versions of the driver are also available.
  • Setup unixODBC.
  • Install CONNECT (unless otherwise specified).

A CONNECT table that points to a SQL Server table is shown below:

#CONNECT Table for MariaDB to SQL Server

CREATE TABLE city (
    id INT PRIMARY KEY,
    city_name VARCHAR(100),
    province_id INT NOT NULL
)
    ENGINE=CONNECT,
    TABLE_TYPE=ODBC,
    TABNAME='city'
    CONNECTION='Driver=SQL Server Native Client 13.0;Server=sql-server-hostname;Database=world;UID=mariadb_connect;PWD=secret';

#MariaDB to SQL Server

Limitations of Using CONNECT Tables in Action for MariaDB to SQL Server Migration

  • Limited historical data: CONNECT Tables in Action only retrieves data from the past 90 days. This prevents access to historical data beyond that timeframe. This restricts analyzing trends or maintaining a complete data archive. 
  • Basic Data Transformation: CONNECT Tables primarily act as a data transfer tool. It lacks the advanced data transformation capabilities required for complex migrations.

6) Linked Server

Instead of using MariaDB CONNECT, SQL Server Linked Server functionality can be used. This allows you to read data from a remote MariaDB database and copy it into SQL Server tables on your local machine. It should be noted, however, that CONNECT gives you more control over type and character set mapping.

Benefits of Migrating Data from MariaDB to SQL Server

MYSQL A Beginner's Guide: Part 2 - Analytics Vidhya
Image Source
  • Simple Installation: MariaDB installation is simple, and it makes your Database Administrators’ lives easier. MariaDB has two installation options: install it as a stand-alone server or configure it to work in conjunction with the Server.
  • Scaling without Interruption: Migrating data from MariaDB to SQL Server is not hard, it can handle billions of records while returning results in seconds. It supports robust parallel processing, which significantly improves the Server’s analytics speed.
  • Greater Business Agility: Industries and businesses are undergoing rapid transformation as a result of frequent market disruption, consumer behavioral changes, etc. Migrating data from MariaDB to SQL Server can provide effective data analytics, deep insights, and the agility required to react and adapt to ever-changing market dynamics.
  • Ad Hoc Data Request Scalability: MariaDB allows you to run queries that aren’t normally part of your workflow. It ensures that you are not limited to analyzing data using only structured methods. It enables your organization to keep the Server foundation flexible and to scale requests as needed.
  • Integration with Different Database Management Systems: MariaDB can easily integrate with different database management systems such as PostgreSQL, MySQL etc. Hence, you can also integrate MariaDB to MSSQL and transformation. 

Use Cases of MariaDB to MSSQL integration

  • Web Application Backend: SQL Server can be used as a backend database for web applications. It stores and manages the data that web applications need, and developers can use SQL queries to interact with the database. Thus, you can prepare a robust web application backend by connecting MariaDb to SQL Server.
  • Data Warehousing: SQL Server has often been used for data warehousing to collect large volumes of data. This is then transformed and loaded for analysis. Features like partitioning and indexing in the SQL Server database engine help optimize the query performance of data warehousing environments.
  • Business Intelligence (BI): There are some features of SQL Server that make it useful for  business intelligence and data analysis. SQL Server Integration Services (SSIS) facilitates the ETL of data. On the other hand, SQL Server Analysis Services (SSAS) supports online analytical processing (OLAP) and data mining.

Before we wrap up, let’s cover some basics as well.

What is MariaDB?

MariaDB, a MySQL clone, is a popular open SQL (Structured Query Language) RDBMS created by MySQL’s original developers. The primary reason for their resemblance is that MariaDB is a software branch of MySQL. The heart of it is the MySQL source code. They are, however, not the same. MariaDB has advanced significantly since 2009 when many MySQL authors created a different version from the same source.

When Oracle Corporation purchased MySQL, the developers were concerned about the future of their product. They were concerned that Oracle would kill MySQL to eliminate a key competitor. They also wanted to ensure that their work was freely accessible. This is how MariaDB first appeared on the scene.

In addition to the Windows version, MariaDB has versions for Linux and macOS. This RDBMS is supported by Intel and IBM Power8 hardware. It is available as a service on Amazon Web Services (AWS), Rackspace Cloud, and Microsoft Azure. The method is easy to learn, safe, and convenient to use. It’s no surprise that it’s gaining popularity.

Key Features of MariaDB

  • SQL Support: MariaDB supports the majority of SQL statements, functions, procedures, definitions, variables, and so on. There are also numerous useful plugins available, such as the audit plugin. All of these features greatly simplify database operations in MariaDB.
  • Thread Pooling: Thread Pooling is a concept that speeds up work on MariaDB when there are multiple connections to the database. Instead of creating a new thread for each connection, MariaDB uses a pool of previously open threads. The query is sent by a new connection, which requires a thread. All searches become faster, resulting in faster results.
  • Compatibility: For data querying, MariaDB employs the widely used SQL language. It is compatible with a wide range of programming languages and operating systems. It runs on Windows and Linux and supports languages such as Python, PHP, C++, Java, JavaScript, Ruby, and others.
  • JSON Compatibility: JSON is a data storage format that is widely used. JSON support is included in all MariaDB 10.2 and later versions.

What is Microsoft SQL Server?

Microsoft SQL Server is a Relational Database Management System (RDBMS). It has hundreds of cores running at the same time and can store petabytes of data. It includes a robust query layer for business analysis and is tightly integrated with reporting solutions such as Power BI. Spark support has been built into newer versions, allowing users to analyze massive amounts of data with Spark SQL without much additional configuration.

Microsoft SQL Server has established itself as a user-friendly, dependable, and effective database system. It operates on ANSI SQL, the industry-standard SQL (Structured Query Language). The SQL Database is vertically scalable, and its robust querying layer aids in business analysis and easily integrates with reporting and visualization tools such as Power BI.

Key Features of SQL Server

Examine the following key features that have contributed to SQL Server’s huge popularity:

  • The Engine of the Database: The Database Engine speeds up trade processing while also streamlining data storage and security.
  • The Agent of the Server: It primarily serves as a project scheduler and can be triggered by any event or in response to a request.
  • SQL Server Explorer: The Server Browser accepts queries and connects them to the appropriate SQL Server instance.
  • Full-Text Search in SQL Server: Customers can perform a full-text search against Character records in SQL Tables, as the name implies.
  • SSRS (SQL Server Reporting Services): Data reporting features and dynamic capacities are provided through Hadoop integration.
  • Support for Cloud Databases: SQL Server can be easily integrated with Azure SQL or Microsoft Cloud and has built-in security. Cloud Database support makes SQL Server more appealing and allows for instant failover with minimal downtime.

Conclusion

This blog has provided an in-depth overview of MariaDB and SQL Server, as well as various methods for copying MariaDB database to SQL Server. There are various Data Sources that organizations leverage to capture a variety of valuable data points. But, transferring data from these sources into a Data Warehouse for a holistic analysis is a hectic task.

It requires you to code and maintains complex functions that can help achieve a smooth flow of data. An Automated Data Pipeline helps in solving this issue and this is where Hevo comes into the picture. Hevo Data is a No-code Data Pipeline and has awesome 150+ pre-built Integrations that you can choose from. You can easily convert MariaDB to SQL server using Hevo Data.

visit our website to explore hevo

Hevo can help you integrate data from 150+ data sources and load them into a destination to analyze real-time data at an affordable Hevo price. It will make your life easier and Data Migration hassle-free. It is user-friendly, reliable, and secure.

SIGN UP for a 14-day free trial and see the difference!

Share your experience on MariaDB to SQL Server migration in the comments section below.

Davor DSouza
Research Analyst, Hevo Data

Davor is a data analyst at heart with a passion for data, software architecture, and writing technical content. He has experience writing more than 100 articles on data integration and infrastructure.

No-code Data Pipeline for SQL Server