Operate the database across servers? it's actually really easy! (under)

At the critical moment, delivered as soon as possible

The previous article taught you how to establish a SQL Server database link (DBLINK) step by step. For detailed steps, please refer to the previous article: Cross-server database operation? it's actually really easy! (on)

Today we will teach you how to connect MYSQL and Oracle remote database

Create MYSQL remote link

The first step is
to download the MYSQL driver file, the specific download address is as follows:

https://dev.mysql.com/downloads/connector/odbc/

Select the download package of the windows version to download and install

After the
driver installation is completed in the second step , we click [Start] —> [Control Panel] —> [Management Tools] —> [ODBC Data Source (64-bit)], and operate as shown in Figure 1 in the pop-up dialog box, as follows Picture:

  • Click [System DSN]

  • Click [Add...] on the right

  • Find the newly installed driver in the pop-up dialog box, select [MySQL ODBC 8.0 Unicode Driver], click Finish to start configuration

Operate the database across servers?  it's actually really easy!  (under)

Figure 1 Add MySQL ODBC driver

In the third step,
click [Finish], and fill in the relevant information as shown in Figure 2 in the pop-up dialog box.

  • First fill in the source database name, this is required, it is best to fill in the other party’s IP address for easy identification, and fill in the custom content for the test here

  • The description department is custom content, you can leave it blank

  • Fill in the other party’s IP address or specific URL in [TCP/IP Server] here, and fill in the port number. The default port number for MySQL is 3306

  • Fill in the user name and password below to verify that they are correct, you can select the database to connect to

  • Click [Test] to test whether the connection is successful, and click [OK] to complete after the connection is successful

Figure 2 MySQL ODBC specific configuration

The fourth step is to
open SSMS—>connect to local database—>server object—>link server, as shown in Figure 3:

Figure 3 Start to create MySQL remote link

The fifth step
is to fill in the relevant information according to the step number in the pop-up dialog box, as shown in Figure 4:

  • The server name is the same as before. This is used when connecting to the target server. It is required.

  • Select other data sources in the server type, and select the driver in step 2

  • The product name is customized, optional

  • The data source is the name of the MySQL ODBC data source we just named

Operate the database across servers?  it's actually really easy!  (under)
Figure 4 Configure MySQL remote link general information

The sixth step is to
select [Security] on the left, and fill in the account and password of the MySQL remote database as shown in Figure 5.

Operate the database across servers?  it's actually really easy!  (under)

Figure 5 Configure MySQL remote link account password

After clicking OK, you can see the created DBLINK on the link server. As shown in Figure 6:

Operate the database across servers?  it's actually really easy!  (under)

Figure 6 Created DBLINK

After the creation is completed, the relevant code will be automatically generated, and the password is hidden with #:


EXEC master.dbo.sp_addlinkedserver 
@server = N'MYSQL', --被访问的服务器别名 
@srvproduct=N'TEST_MYSQL', 
@provider=N'MSDASQL', 
@datasrc=N'TEST' --要访问的服务器,这里是ODBC的名称

EXEC master.dbo.sp_addlinkedsrvlogin
@rmtsrvname=N'MYSQL', --被访问的服务器别名
@useself=N'False',
@locallogin=NULL,
@rmtuser=N'rdsadmin', --用户名
@rmtpassword='########'  --密码

We can use the created DBLINK to link to the other party's server. The verification method is the same as that in the previous article, so I won't repeat it here.

Create Oracle remote link

Connecting to an Oracle remote server is similar to connecting to MySQL, except that the driver and driver configuration are different. Let's do it together

The first step is
to go to the Oracle official website to download the ODBC driver, the download link:

http://www.oracle.com/technetwork/cn/topics/winx64soft-101515-zhs.html

Download the following two installation packages:

instantclient-basiclite-win-x86-64-11.2.0.1.0.zip

instantclient-odbc-win-x86-64-11.2.0.1.0.zip

Unzip and install after downloading.

After the
driver installation is completed in the second step , we click [Start] —> [Control Panel] —> [Management Tools] —> [ODBC Data Source (64-bit)], and operate as shown in Figure 7 in the pop-up dialog box, as follows Picture:

  • Click [System DSN]

  • Click [Add...] on the right

  • Select [Oracle in OraDb11g_home1] in step 3

Operate the database across servers?  it's actually really easy!  (under)

Figure 7 Add Oracle's ODBC

In the third step,
click Finish and enter the relevant information in the pop-up dialog box, as shown in Figure 8:

  • First fill in the source database name, this is required, it is best to fill in the other party’s IP address for easy identification, and fill in the custom content for the test here

  • The description department is custom content, you can leave it blank

  • Fill in the TNS information of the database, including IP address: port number/instance name

  • Fill in the user name of the database in step 3

  • Click on the [Test Connection] on the right, the dialog box shown in Figure 9 will pop up, enter the password

Operate the database across servers?  it's actually really easy!  (under)

Figure 8 Configure Oracle's ODBC information

Operate the database across servers?  it's actually really easy!  (under)

Figure 9 Configure Oracle's ODBC information

The fourth step is to
open SSMS—>connect to local database—>server object—>link server, as shown in Figure 3:

Operate the database across servers?  it's actually really easy!  (under)

Figure 10 Start to create Oracle remote link

The fifth step
is to fill in the relevant information according to the serial number in the pop-up dialog box, as shown in Figure 11:

  • The server name is the same as before, this one is used to connect to the target server.

  • Select other data sources in the server type, and select the driver in step 2

  • The product name is customized, optional

  • The data source is the name of the Oracle ODBC data source we just named

Operate the database across servers?  it's actually really easy!  (under)

Figure 11 Configure Oracle remote link general information

The sixth step is to
select [Security] on the left, and fill in the account and password of the Oracle remote database as shown in Figure 12.

Operate the database across servers?  it's actually really easy!  (under)

Figure 12 Configure Oracle remote link account password

After clicking OK, you can see the created DBLINK on the link server. As shown in Figure 6:

Operate the database across servers?  it's actually really easy!  (under)

Figure 13 DBLINK created

After the creation is completed, the relevant code will be automatically generated, and the password is hidden with #:


EXEC master.dbo.sp_addlinkedserver 
@server = N'OA', --被访问的服务器别名 
@srvproduct=N'Oracle', 
@provider=N'MSDASQL', 
@datasrc=N'OA' --要访问的服务器,这里是ODBC的名称

EXEC master.dbo.sp_addlinkedsrvlogin 
@rmtsrvname=N'OA',--被访问的服务器别名 
@useself=N'False',
@locallogin=NULL,
@rmtuser=N'user',--用户名
@rmtpassword='########' --密码

At this point, the entire DBLINK technology sharing is over. If you don't understand, you can leave a message for me, and I will reply one by one.

Guess you like

Origin blog.51cto.com/15057820/2656425