【发布时间】:2018-03-07 00:34:42
【问题描述】:
在为我在 Elastic Beanstalk 上运行的 Rails 应用程序设置 AWS RDS 时遇到问题。我关注了the docs,但是当它尝试运行迁移时,我得到了 MySQL 语法错误。很确定我没有语法错误,因为迁移在本地运行良好,并且我成功设置了暂存并且错误在第一行。我在想这可能与安全组阻止流量有关,但我适当地更新了入站规则,但仍然出现错误:
3306 tcp 173.8.166.54/32, sg-3221b354 <- RDs Security Group
80 tcp 0.0.0.0/0, ::/0, sg-3b31a75d
22 tcp 0.0.0.0/0
443 tcp 0.0.0.0/0
我为数据库设置了环境变量。我错过了什么?
我得到的错误:发生在第一次迁移的第一行
Mysql2::Error: 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“json、
imagevarchar(255)、codevarchar(255)、created_atdatetime NOT NULL,”附近使用正确的语法:CREATE TABLEcoupons(idint AUTO_INCREMENT PRIMARY KEY,productvarchar(255),offervarchar(255),sizevarchar(255),descriptionvarchar(25@5), @98765433 987654333@ varchar(255),codevarchar(255),created_atdatetime NOT NULL,updated_atdatetime NOT NULL) ENGINE=InnoDB /var/app/ondeck/db/migrate/20170725193230_create_coupons.rb:3:inchange' /opt/rubies/ruby-2.3.4/bin/bundle:22:inload' /opt/rubies/ruby-2.3.4/bin/bundle:22:in<main>' ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'json,imagevarchar(255),codevarchar(255),created_atdatetime NOT NULL,' at line 1: CREATE TABLEcoupons(idint AUTO_INCREMENT PRIMARY KEY,productvarchar(255),offervarchar(255),sizevarchar(255),descriptionvarchar(255),infojson,imagevarchar(255),codevarchar(255),created_atdatetime NOT NULL,updated_atdatetime NOT NULL) ENGINE=InnoDB /var/app/ondeck/db/migrate/20170725193230_create_coupons.rb:3:inchange' /opt/rubies/ruby-2.3.4/bin/bundle:22:inload' /opt/rubies/ruby-2.3.4/bin/bundle:22:in' Mysql2::Error: 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 'json,imagevarchar(255),codevarchar(255),created_atdatetime NOT NULL,' 附近使用正确的语法 /var/app/ondeck/db/migrate/20170725193230_create_coupons.rb:3:in `change'
有问题的迁移:
class CreateCoupons < ActiveRecord::Migration[5.0]
def change
create_table :coupons do |t|
t.string :product
t.string :offer
t.string :size
t.string :description
t.json :info
t.string :image
t.string :code
t.timestamps
end
end
end
【问题讨论】:
-
您为哪个安全组显示规则?实例?还是 RDS? sg-3221b354 是您的 RDS 实例或 EB 实例的 sec 组吗?
-
你遇到了什么错误?
-
@Brian 更新错误
-
@strongjz 我正在显示我的实例的入站规则。它包括 2 个安全组,一个是为实例创建的,一个是为 rds 创建的。 rds sg 在 3306 上有自己的规则。我按照文档中的步骤操作。
-
我认为这与您的安全组无关。您是否在本地运行与在 RDS 中相同版本的 MySQL?
标签: mysql ruby-on-rails amazon-web-services amazon-rds amazon-elastic-beanstalk