简体   繁体   English

Rails连接到远程mysql数据库

[英]rails connect to remote mysql database

I'm actually deploying my app to Rackspace and trying to use their cloud database service with mysql. 我实际上是在将我的应用程序部署到Rackspace并尝试将其云数据库服务与mysql一起使用。

as it's a remote database, i'm sure i have to add the gem for mysql to my gemfile, but i'm not sure if i need to install mysql in my app server (that does not make sense to me). 因为它是一个远程数据库,所以我确定必须将mysql的gem添加到我的gemfile中,但是我不确定是否需要在我的应用服务器中安装mysql(这对我来说没有意义)。

Should i install it on my server? 我应该在服务器上安装它吗? is there other way to go or i'm missing something? 还有其他方法要走吗,或者我想念什么?

Any advice will be appreciated. 任何建议将被认真考虑。

Log Error 记录错误

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/home/admin/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb 
An error occurred while installing mysql2 (0.3.16), and Bundler cannot continue.

but i'm not sure if i need to install mysql in my app server (that does not make sense to me). 但是我不确定是否需要在我的应用服务器中安装mysql(对我来说这没有意义)。

Yes you do. 是的你是。

We use Rackspace too - something you might want to know their cloud MYSQL instances can only be accessed from servers inside their datacenters. 我们也使用Rackspace-您可能想知道它们的云MYSQL实例只能从其数据中心内的服务器进行访问。 Amazing security :) 惊人的安全性:)

-- -

MYSQL MYSQL

You have to install MYSQL on your app server because MYSQL connectivity needs the MYSQL headers to connect to a third-party database. 您必须在应用服务器上安装MYSQL,因为MYSQL连接需要使用MYSQL标头才能连接到第三方数据库。 This is only possible with the linux (I presume) headers on your system. 在您系统上的linux(我认为)标头中才有可能。

If you're running Linux, you may wish to reference this question : 如果您使用的是Linux,则不妨参考以下问题

sudo apt-get install libmysql-ruby libmysqlclient-dev 须藤apt-get install libmysql-ruby libmysqlclient-dev

This will allow you to instal the MYSQL header files, which should let the MYSQL gem install for you. 这将允许您安装MYSQL头文件,这将让MYSQL gem为您安装。 This will not run a local MYSQL server; 这将不会运行本地MYSQL服务器。 just provide you with the necessary DLL files to help it connect to your actual mysql server 只需为您提供必要的DLL文件,以帮助它连接到实际的mysql服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM