在触发器中访问远程mysql数据库 [英] Accessing to a remote mysql db in trigger

查看:86
本文介绍了在触发器中访问远程mysql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个日志解析应用程序,我需要根据我的发现在另一个mysql服务器上进行查询.(即:该域的用户ID是什么)

I've a log parsing application and I need to make a query on an another mysql server based on my findings. (ie: what is the userID for this domain)

是否可以在触发器中连接另一个mysql服务器以获取信息并在插入前"事件上更新记录?

is it possible to connect another mysql server in a trigger to pull information and update the record on "before insert" event?

谢谢

推荐答案

FEDERATED存储引擎解决了我的问题.我创建了一个带有远程连接的表,它保留了远程表的副本.

FEDERATED storage engine solved my issue. I created a table with remote connection and it keeps copy of remote table.

CREATE TABLE `domains` (
    `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
    `user_id` BIGINT(20) UNSIGNED NOT NULL
    PRIMARY KEY (`id`),
    INDEX `user_id` (`user_id`),
)
COLLATE='latin1_swedish_ci'
ENGINE=FEDERATED
DEFAULT CHARSET=latin1
CONNECTION='mysql://user:pass@host:port/database/domains';

感谢 inhan 显示正确的方向.

这篇关于在触发器中访问远程mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆