Author: Hassan Shareef,
Database Administrator
Since 16 years
In this guide, I will show step-by-step how to transfer data from Oracle to MySQL using MySQL Workbench tool. As you must be already knowing that MySQL Workbench is a free tool which can be downloaded from MySQL website. The Workbench is specially made for managing MySQL databases through graphical user interface. It also comes with Migration Wizard for importing and exporting data from MySQL. We will be using this tool for our example. So let's start!
MySQL Workbench installed (Download from MySQL Website).
Oracle ODBC Driver (e.g., Oracle Instant Client ODBC). Download from Oracle.
Access credentials for Oracle (source) and MySQL (target) databases.
Download the Oracle ODBC driver
Install the driver:
Oracle Instant Client: Extract the package and configure the driver via the ODBC Data Source Administrator.
Open the ODBC Data Source Administrator:
Windows: Search for "ODBC Data Sources" in the Start menu.
macOS/Linux: Use iodbc
or unixODBC
utilities.
Create a System DSN for Oracle:
Go to the System DSN tab and click Add.
Select the installed Oracle ODBC driver.
Configure connection details:
Data Source Name: A custom name (e.g.,
Oracle_DSN
).
Host/IP: Oracle server address.
Port: 1521
(default).
Service Name/SID: Oracle database service name.
Username/Password: Oracle credentials.
Test the connection and save the DSN.
Open MySQL Workbench and navigate to Database > Migration
Wizard.
Source Database:
Click Start Migration Button
Select ODBC as the source type.
Enter the DSN name (Oracle_DSN
) and Oracle
credentials.
Target Database:
Configure MySQL connection details (host, port, username, password).
Test both connections before proceeding.
Fetch Source Schema:
Select the Oracle schema(s) to migrate. We will use the the sample HR demo schema for the purpose of this guide.
MySQL Workbench will auto-convert Oracle objects to MySQL syntax. Adjustments may be needed:
Data Types: Map Oracle NUMBER
to MySQL INT
or DECIMAL
,
VARCHAR2
to VARCHAR
, etc.
Reserved Keywords: Escape MySQL keywords
with backticks (e.g., `order`
).
Manual Adjustments:
Modify indexes, triggers, or constraints as needed.
Handle unsupported features (e.g., Oracle-specific functions).
Select Tables:
Choose tables to migrate. Use filters to exclude unnecessary data.
Data Mapping:
Map Oracle columns to MySQL columns, adjusting data types if required.
For large datasets, enable batch processing (e.g., 10,000 rows per batch).
Import Modes:
Append: Add new records to MySQL.
Replace: Overwrite existing data.
Use the Truncate Table option if starting fresh.
Start the migration and monitor logs for errors.
Compare row counts between Oracle and MySQL:
-- Oracle
SELECT COUNT(*) FROM employees;
-- MySQL
SELECT COUNT(*)
FROM employees;
Validate data consistency for critical fields (e.g., dates, unique IDs).
Use tools like OracleSync2MySQL
for automated data
comparison
ODBC vs. JDBC: ODBC is more resource-efficient and supports cross-platform compatibility 4.
Architecture Mismatch: Ensure the ODBC driver and application (e.g., MySQL Workbench) are both 32-bit or 64-bit 8.
Performance:
Disable foreign key checks during migration:
SET FOREIGN_KEY_CHECKS = 0; -- Run migration SET FOREIGN_KEY_CHECKS = 1;
Tools Use Data Loader for a GUI-driven migration with advanced mapping features.
For automated large-scale migration, try Oracle to MySQL Converter
Connection Errors: Verify the DSN configuration and firewall settings.
Data Truncation: Adjust column lengths in MySQL
(e.g., VARCHAR(255)
for Oracle VARCHAR2(50)
).
Unicode Issues: Ensure the ODBC driver supports UTF-8 encoding.