如何在Google Cloud SQL中创建联合表 [英] How do I create a Federated Table in Google Cloud SQL

查看:102
本文介绍了如何在Google Cloud SQL中创建联合表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Joomla(PHP)网站,带有一个现有的托管MySQL数据库. 我有一个Google Cloud SQL实例,其中包含一些统计数据.

I have a Joomla (PHP) website with an existing hosted MySQL database. I have a Google Cloud SQL Instance with some statistical data in.

我需要在两个数据库中查询数据,并且希望该查询在Google Cloud SQL实例上运行.

I need to query the data across both databases and would like the query to run on the Google Cloud SQL instance.

到目前为止,我的研究使我相信,执行此操作的最佳方法是在Google Cloud SQL数据库中创建一个联合表,但是在尝试执行此操作时,我没有得到我期望的结果(我也没有得到错误?!)

My research so far has lead me to belive that the best way to do this is to create a federated table inside the Google Cloud SQL database but in attempting to do this I am not getting the results I expect (neither am I getting an error?!)

Joomla MySQL表:

Joomla MySQL table:

CREATE TABLE test_table (
  id INT(20) NOT NULL AUTO_INCREMENT,
  name VARCHAR(32) NOT NULL DEFAULT '',
  other INT(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (id),
  INDEX name (name),
  INDEX other_key (other)
)
ENGINE=MyISAM
DEFAULT CHARSET=latin1;

Google Cloud SQL:

Google Cloud SQL:

CREATE TABLE federated_table (
  id INT(20) NOT NULL AUTO_INCREMENT,
  name VARCHAR(32) NOT NULL DEFAULT '',
  other INT(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (id),
  INDEX name (name),
  INDEX other_key (other)
)
ENGINE=FEDERATED
DEFAULT CHARSET=latin1
CONNECTION='mysql://*uid*:*pwd*@*joomla_server_ip*:3306/*database_name*/test_table';

哪里

*uid*, *pwd*, *joomla_server_ip* and *database_name* 

是所有有效值.

两个语句都能正常执行,没有错误,但是在将数据插入Joomla上的* test_table *之后,我无法在Google Cloud SQL的* federated_table *中看到任何数据.

Both statements execute fine with no errors, but after inserting data to *test_table* on Joomla I am unable to see any data in *federated_table* on Google Cloud SQL.

我已经尝试使用命令行工具(Windows)和SQuirrel SQL JDBC客户端来创建联合表.

I have tried the federated table creation using both the command line tool (Windows) and using the SQuirrel SQL JDBC client.

因为我没有看到任何错误,所以我不确定是Joomla数据库端还是Google Cloud SQL数据库端.因此,任何帮助将不胜感激.我以为这是两个数据库之间的连接问题,但是可以尝试您可能会提出的其他理论.

Because I am seeing no errors what so ever I'm not sure if the problem is at the Joomla database end or the Google Cloud SQL database end. So any help will be greatly appreciated. I am assuming the problem is with the connection between the two databases, but am open to trying any other theroies that you may throw at me.

我现在正在使用其他客户端(MySQL Workbench)进行连接,并且在尝试执行相同操作时会报告错误

I'm now using a different client to connect (MySQL Workbench) and this reports an error when trying to do the same thing

1286 Unknown storage engine 'FEDERATED' 1266 Using storage engine InnoDB for table 'federated_table'

推荐答案

在问了这个问题后不久,Google将MySQL Wire Protocol添加到Google Cloud SQL.

Shortly after asking this question Google added the MySQL Wire Protocol to Google Cloud SQL.

http://googlecloudplatform.blogspot.co.uk/2013/10/google-cloud-sql-now-accessible-from-any-application-anywhere.html

现在可以以正常方式创建联合表.

It is now possible to create Federated tables in the normal way.

这篇关于如何在Google Cloud SQL中创建联合表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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