Connect to remote host from within MySql stored procedure [duplicate]
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.
精彩评论