Scripting - SQL Server to Aurora MySQL Migration Playbook
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).


Feature compatibility Amazon SCT / Amazon DMS automation level Amazon SCT action code index Key differences

                              No feature compatibility



Non-compatible tool sets and scripting languages. Use MySQL Workbench, Amazon RDS API, Amazon Management Console, and Amazon CLI.

SQL Server Usage

SQL Server supports T-SQL and XQuery scripting within multiple run frameworks such as SQL Server Agent, and stored procedures.

The SQLCMD command line utility can also be used to run T-SQL scripts. However, the most extensive and feature-rich scripting environment is PowerShell.

SQL Server provides two PowerShell snap-ins that implement a provider exposing the entire SQL Server Management Object Model (SMO) as PowerShell paths. Additionally, you can use cmd in SQL Server to run specific SQL Server commands.


You can use Invoke-Sqlcmd to run scripts using the SQLCMD utility.

The sqlps utility launches the PowerShell scripting environment and automatically loads the SQL Server modules. You can launch sqlps from a command prompt or from the Object Explorer pane of SQL Server Management Studio. You can run one-time PowerShell commands and script files (for example, .\SomeFolder\SomeScript.ps1).


SQL Server Agent supports running PowerShell scripts in job steps. For more information, see SQL Server Agent and MySQL Agent.

SQL Server also supports three types of direct database engine queries: T-SQL, XQuery, and the SQLCMD utility. You can call T-SQL and XQuery from stored procedures, SQL Server Management Studio (or other IDE), and SQL Server agent jobs. The SQLCMD utility also supports commands and variables.


Backup a database with PowerShell using the default backup options.

PS C:\> Backup-SqlDatabase -ServerInstance "MyServer\SQLServerInstance" -Database "MyDB"

Get all rows from the MyTable table in the MyDB database.

PS C:\> Read-SqlTableData -ServerInstance MyServer\SQLServerInstance" -DatabaseName "MyDB" -TableName "MyTable"

For more information, see SQL Server PowerShell, Database Engine Scripting, and sqlcmd Utility in the SQL Server documentation.

MySQL Usage

As a Platform as a Service (PaaS), Aurora MySQL accepts connections from any compatible client, but you can’t access the MySQL command line utility typically used for database administration. However, you can use MySQL tools installed on a network host and the Amazon RDS API. The most common tools for Aurora MySQL scripting and automation include MySQL Workbench, MySQL Utilities, and the Amazon RDS API. The following sections describe each tool.

MySQL Workbench

MySQL Workbench is the most commonly used tool for development and administration of MySQL servers. It is available as a free Community Edition and a paid Commercial Edition that adds enterprise features such as database documentation features. MySQL Workbench is an integrated IDE with the following features:

  • SQL Development — Manage and configure connections to aurora MySQL clusters and run SQL queries using the SQL editor.

  • Data Modeling — Reverse and forward engineer graphical database schema models and manage schemas with the Table Editor.

  • Server Administration — Not applicable to Aurora MySQL. Use the Amazon RDS console to administer servers.

The MySQL Workbench also supports a Python scripting shell that you can use interactively and programmatically.

MySQL Utilities

MySQL Utilities are a set of Python command line tools used for common maintenance and administration of MySQL servers tasks. They can reduce the need to write custom code for common tasks and can be easily customized.

The following tools are included in the MySQL Utilities set. Note that some tools will not work with Aurora MySQL because you don’t have root access to the underlying server.

  • Admin utilities — Clone, Copy, Compare, Diff, Export, Import, and User Management.

  • Replication utilities — Setup, Configuration, and Verification

  • General utilities — Disk Usage, Redundant Indexes, Manage Metadata, and Manage Audit Data

Amazon RDS API

The Amazon RDS API is a web service for managing and maintaining Aurora PostgreSQL and other relational databases. You can use Amazon RDS API to setup, operate, scale, backup, and perform many common administration tasks. The Amazon RDS API supports multiple database platforms and can integrate administration seamlessly for heterogeneous environments.


The Amazon RDS API is asynchronous. Some interfaces may require polling or callback functions to receive command status and results.

You can access Amazon RDS using the Amazon Management Console, the Amazon Command Line Interface (CLI), and the Amazon RDS Programmatic API as described in the following sections.

Amazon Management Console

The Amazon Management Console is a simple web-based set of tools for interactive management of Aurora PostgreSQL and other Amazon RDS services. To access the Amazon Management Console, sign in to your Amazon account, and choose RDS.

Amazon Command Line Interface

The Amazon Command Line Interface is an open source tool that runs on Linux, Windows, or macOS having Python 2 version 2.6.5 and higher or Python 3 version 3.3 and higher.

The Amazon CLI is built on top of the Amazon SDK for Python (Boto), which provides commands for interacting with Amazon services. With minimal configuration, you can start using all Amazon Management Console functionality from your favorite terminal application.

  • Linux shells — Use common shell programs such as Bash, Zsh, or tsch.

  • Windows command line — Run commands in PowerShell or the Windows Command Processor.

  • Remotely — Run commands on Amazon EC2 instances through a remote terminal such as PuTTY or SSH.

The Amazon Tools for Windows PowerShell and Amazon Tools for PowerShell Core are PowerShell modules built on the functionality exposed by the Amazon SDK for .NET. These Tools enable scripting operations for Amazon resources using the PowerShell command line.


You can’t use SQL Server cmdlets in PowerShell.

Amazon RDS Programmatic API

You can use the Amazon RDS API to automate management of database instances and other Amazon RDS objects.

For more information, see Actions, Data Types, Common Parameters, and Common Errors in the Amazon Relational Database Service API Reference.


The following walkthrough describes how to connect to an Aurora MySQL database instance using the MySQL utility.

  1. Sign in to your Amazon account, choose RDS, and then choose Databases.

  2. Choose the MySQL database you want to connect to and copy the cluster endpoint address.


    You can also connect to individual database instances. For more information, see High Availability Essentials.

  3. In the command shell, enter the following:

    mysql -h <mysql-instance-endpoint-address> -P 3306 -u MasterUser

    In the preceding example, the -h parameter is the endpoint Domain Name System (DNS) name of the Aurora MySQL database cluster.

    In the preceding example, the -P parameter is the port number.

  4. Provide the password when prompted. The system displays the following (or similar) message.

    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 350
    Server version: 5.6.27-log MySQL Community Server (GPL)
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

For more information, see MySQL Product Archives, MySQL Workbench 8.0.29, Command Line Interface, and Amazon Relational Database Service API Reference.