开发者

Connect to remote host from within MySql stored procedure [duplicate]

开发者 https://www.devze.com 2023-04-03 08:11 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate: can I access a remote mysql server/db from a stored procedure?
This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

can I access a remote mysql server/db from a stored procedure?

I'm a bit 开发者_开发技巧new to MySQL. I want to create a stored routine that accepts a parameter and returns a dataset to a Read-Only user.

Within the stored routine, however, I want to establish a new connection (using different credentials) to a remote MySQL host and read the required values based on the input parameter.

I imagine it would go like this:

CREATE PROCEDURE procReturnsData(parameter1)
BEGIN
     <connect to remote MySQL server using new credentials>
     <Select col1, col2 from remoteServer.table1 Where col3 = parameter1 >
     <close connection>
END

What's the best way to achieve this?

Thanks.


Using federated tables, you can create a remote table.

Unfortunately, I don't think it works with SSH without creating a tunnel at the OS level first.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号