如何验证 mysql 数据库 URI

Vas*_*asu 6 mysql ruby-on-rails mysql2

我正在尝试将名为 blazer 的 Gem 与我的 Rails 应用程序集成,并且必须在 blazer.yml 文件中指定 mysql 数据库 URL,以便它可以访问临时和生产环境中的数据。

我相信定义 MySQL 数据库 URL 的标准格式是

mysql2://user:password@hostname:3306/database
Run Code Online (Sandbox Code Playgroud)

我以与字符串相同的格式定义了 URL,当我验证 URI 时,出现以下错误

URI::InvalidURIError:错误的 URI(不是 URI?):mysql2://f77_oe_85_staging:LcCh%264855c6M;kG9yGhjghjZC?JquGVK@factory97-aurora-staging-cluster.cluster-cmj77682fpy4kjl.us-east-1.rds.amazonaws。 com/factory97_oe85_staging

定义Mysql数据库URL:

'mysql2://f77_oe_85_staging:LcCh%264855c6M;kG9yGhjghjZC?JquGVK@factory97-aurora-staging-cluster.cluster-cmj77682fpy4kjl.us-east-1.rds.amazonaws.com/factory97_oe85_staging'
Run Code Online (Sandbox Code Playgroud)

请指教

Sch*_*ern 5

URI 无效。

问题是密码包含在 URI 中无效的字符。是URI 的一部分username:passworduserinfo来自RFC 3986 ...

  foo://example.com:8042/over/there?name=ferret#nose
  \_/   \______________/\_________/ \_________/ \__/
   |           |            |            |        |
scheme     authority       path        query   fragment

authority   = [ userinfo "@" ] host [ ":" port ]
userinfo    = *( unreserved / pct-encoded / sub-delims / ":" )

pct-encoded = "%" HEXDIG HEXDIG
unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
            / "*" / "+" / "," / ";" / "="
Run Code Online (Sandbox Code Playgroud)

具体来说就是?密码中的LcCh%264855c6M;kG9yGhjghjZC?JquGVK。看起来密码只被部分转义。