连接到 MySQL (MySQLToSQL)Connecting to MySQL (MySQLToSQL)

若要将 MySQL 数据库迁移到 SQL Server 或 SQL Azure,你必须连接到要迁移的 MySQL 数据库。To migrate MySQL databases to SQL Server or SQL Azure, you must connect to the MySQL database that you want to migrate. 在连接时,SSMA 将获取有关所有 MySQL 架构的元数据,然后在 "MySQL 元数据资源管理器" 窗格中显示该架构。When you connect, SSMA obtains metadata about all MySQL schemas, and then displays it in the MySQL Metadata Explorer pane. SSMA 存储有关数据库服务器的信息,但不存储密码。SSMA stores information about the database server, but does not store passwords.

在关闭项目之前,与数据库的连接保持活动状态。Your connection to the database stays active until you close the project. 重新打开项目时,如果要连接到数据库,则必须重新连接。When you reopen the project, you must reconnect if you want an active connection to the database.

不会自动更新有关 MySQL 数据库的元数据。Metadata about the MySQL database is not automatically updated. 相反,如果要更新 MySQL 元数据资源管理器中的元数据,则必须手动更新。Instead, if you want to update the metadata in MySQL Metadata Explorer, you must manually update it. 有关详细信息,请参阅本主题后面的 "刷新 MySQL 元数据" 一节。For more information, see the "Refreshing MySQL Metadata" section later in this topic.

必需的 MySQL 权限Required MySQL Permissions

用于连接到 MySQL 数据库的帐户至少必须具有 connect 权限。The account that is used to connect to the MySQL database must have at least CONNECT permissions. 这使 SSMA 可以从连接用户所拥有的架构中获取元数据。This enables SSMA to obtain metadata from schemas owned by the connecting user. 若要获取其他架构中的对象的元数据,然后转换这些架构中的对象,该帐户必须具有以下权限:To obtain metadata for objects in other schemas and then convert objects in those schemas, the account must have the following permissions:

  • 对数据库对象的 "显示" 权限'SHOW' privileges on database objects

  • "Information_schema" 上的 "选择" 特权'SELECT' privilege on 'Information_schema'

  • 针对 Udf 的 mysql (上的 "选择" 特权) 'SELECT' privilege on mysql (for UDFs)

与 MySQL 建立连接Establishing a Connection to MySQL

连接到数据库时,SSMA 将读取数据库元数据,然后将此元数据添加到项目文件。When you connect to a database, SSMA reads the database metadata, and then adds this metadata to the project file. 当 SSMA 将对象转换为 SQL Server 或 SQL Azure 语法,并在将数据迁移到 SQL Server 或 SQL Azure 时,此元数据由使用。This metadata is used by SSMA when it converts objects to SQL Server or SQL Azure syntax, and when it migrates data to SQL Server or SQL Azure. 可以在 MySQL 元数据资源管理器窗格中浏览此元数据,并查看单个数据库对象的属性。You can browse this metadata in the MySQL Metadata Explorer pane and review properties of individual database objects.

重要

尝试连接之前,请确保数据库服务器正在运行,并且可以接受连接。Before you try to connect, make sure that the database server is running and can accept connections.

连接到 MySQLTo connect to MySQL

  1. 在 " 文件 " 菜单上,选择 " 连接到 MySQL (在创建项目) 后将启用此选项。On the File menu, select Connect to MySQL (this option will be enabled after the creation of project).

    如果以前已连接到 MySQL,则命令名称将 重新连接到 mysqlIf you are previously connected to MySQL, the command name will be Reconnect to MySQL.

  2. 在 " 提供程序 " 框中,选择 "MySQL ODBC 5.1 驱动程序 (信任的) "。In the Provider box, select MySQL ODBC 5.1 Driver (trusted). 它是 "标准" 模式下的默认提供程序。It is the default provider in the standard mode.

  3. 在 " 模式 " 框中,选择 " 标准模式"。In the Mode box, select Standard mode. 它是默认模式。It is the default mode.

    使用 "标准" 模式指定服务器名称和端口。Use standard mode to specify the server name and port.

  4. 在 " 标准" 模式 下,提供下列值:In Standard mode, provide the following values:

    1. 在 " 服务器名称 " 框中,输入 MySQL 服务器名称。In the Server name box, enter the MySQL server name. 在 " 服务器端口 " 框中,输入要为3306的端口号。In the Server port box, enter the port number to be 3306. 它是默认端口。It is the default port.

    2. 在 " 用户名 " 框中,输入具有所需权限的 MySQL 帐户。In the User name box, enter a MySQL account that has the necessary permissions.

    3. 在 " 密码 " 框中,输入指定用户名的密码。In the Password box, enter the password for the specified user name.

  5. SSL: 如果希望安全地连接到 MySQL,请通过选中 " ssl " 复选框, (ssl) 使用安全套接字层。SSL: If you want to securely connect to MySQL, make use of Secure Socket Layer (SSL) by checking the SSL checkbox.

  6. 配置: 它提供了一个选项,用于通过安全套接字层 (SSL) 配置与 MySQL 的连接。Configure: It provides an option to configure the connection to MySQL through Secure Socket Layer (SSL).

    备注

    若要启用 配置,SSL 必须设置为 TrueTo enable Configure, SSL must be set to True.

    单击 "配置" 按钮时,会显示一个对话框。On clicking the button "Configure", a dialog-box appears. 若要在连接到 MySQL 数据库时使用加密,必须定义该对话框中提供的以下三个证书文件的路径 [隐私增强邮件证书 (PEM) ]:To use encryption while connecting to MySQL Database, path to the following three certificate files present in the dialog-box must be defined [Privacy Enhanced Mail Certificates (PEM)]:

    • SSL 证书颁发机构: 指定带有可信 SSL Ca 列表的文件的路径。SSL Certificate Authority: Specifies the path to a file with a list of trust SSL CAs'.

    • SSL 证书: 指定用于建立安全连接的 SSL 证书文件的名称。SSL Certificate: Specifies the name of the SSL certificate file to use for establishing a secure connection.

    • SSL 密钥: 指定用于建立安全连接的 SSL 密钥文件的名称。SSL KEY: Specifies the name of the SSL key file to use for establishing a secure connection.

    备注

    • 如果提供了所需的信息,则 " 确定 " 按钮处于启用状态。The OK button is enabled when the required information has been provided. 如果任何文件路径无效,则 "确定" 按钮将保持禁用状态。If any of the file paths are invalid, the "OK" button will remain disabled.
    • " 取消 " 按钮关闭对话框,并从主连接窗体 禁用 SSL 选项。The Cancel button closes the dialog box and turns off the SSL option from the main Connection Form.
  7. 有关详细信息,请参阅 连接到 MySQL (MySQLToSQL)For more information, see Connect to MySQL (MySQLToSQL)

重新连接到 MySQLReconnecting to MySQL

与数据库服务器的连接会一直保持活动状态,直到关闭该项目。Your connection to the database server stays active until you close the project. 重新打开项目时,如果要连接到数据库,则必须重新连接。When you reopen the project, you must reconnect if you want an active connection to the database. 你可以脱机工作,直至你要更新元数据、将数据库对象加载到 SQL Server 或 SQL Azure,以及迁移数据。You can work offline until you want to update metadata, load database objects into SQL Server or SQL Azure, and migrate data.

刷新 MySQL 元数据Refreshing MySQL Metadata

不会自动刷新有关 MySQL 数据库的元数据。Metadata about the MySQL database is not automatically refreshed. MySQL 元数据资源管理器中的元数据是首次连接时或上次手动刷新元数据时的元数据的快照。The metadata in MySQL Metadata Explorer is a snapshot of the metadata when you first connected, or the last time that you manually refreshed metadata. 可以手动更新所有架构、单个架构或单个数据库对象的元数据。You can manually update metadata for all schemas, a single schema, or individual database objects.

刷新元数据To refresh metadata

  1. 请确保已连接到数据库。Make sure that you are connected to the database.

  2. 在 MySQL 元数据资源管理器中,选中要更新的每个架构或数据库对象旁边的复选框。In MySQL Metadata Explorer, select the check box next to each schema or database object that you want to update.

  3. 右键单击 " 架构"、单个架构或数据库对象,然后选择 " 从数据库刷新"。Right-click Schemas, or the individual schema or database object, and then select Refresh from Database.

    如果没有活动连接,SSMA 将显示 " 连接到 MySQL " 对话框,以便你可以连接。If you do not have an active connection, SSMA will display the Connect to MySQL dialog box so that you can connect.

  4. 在 "从数据库刷新" 对话框中,指定要刷新的对象。In the Refresh from Database dialog box, specify which objects to refresh.

    • 若要刷新对象,请单击对象旁边的 活动 字段,直到出现箭头。To refresh an object, click the Active field adjacent to the object until an arrow appears.

    • 若要防止对象被刷新,请单击对象旁边的 活动 字段,直到出现 XTo prevent an object from being refreshed, click the Active field adjacent to the object until an X appears.

    • 若要刷新或拒绝某个对象类别,请单击 "category" 文件夹旁边的 活动 字段。To refresh or decline a category of objects, click the Active field adjacent to the category folder.

    • 若要查看颜色编码的定义,请单击 " 图例 " 按钮。To view the definitions of the color coding, click the Legend button.

  5. 单击“确定”。Click OK.

下一步Next Step

迁移过程的下一步是 连接到 SQL Server (MySQLToSQL)The next step in the migration process is Connecting to SQL Server (MySQLToSQL)

另请参阅See Also

将 MySQL 数据库迁移到 SQL Server-Azure SQL 数据库 (MySQLToSql)Migrating MySQL Databases to SQL Server - Azure SQL Database (MySQLToSql)