【问题标题】:Rails db:create collation errorRails db:创建排序规则错误
【发布时间】:2009-10-01 16:02:30
【问题描述】:

我在运行 rake db:create 时遇到问题:

[root@zephyrnode /domain/rails/testapp ]# rake db:create --trace
(in /domain/rails/testapp)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
Couldn't create database for {"adapter"=>"mysql", "encoding"=>"utf8", "collation"=>"utf8_bin", "reconnect"=>false, "database"=>"testapp_development", "pool"=>5, "username"=>"root", "password"=>"rootpass", "socket"=>"/var/run/mysqld/mysqld.sock", "host"=>"127.0.0.1"}, charset: utf8, collation: utf8_bin (if you set the charset manually, make sure you have a matching collation)

我在下面附上了我能想到的所有可能的版本和设置信息。我已经尝试了在谷歌上找到的所有解决方案,但都没有运气。有没有人有任何解决方案或建议?谢谢!

[root@zephyrnode /domain/rails/testapp ]# mysql --version
mysql  Ver 14.14 Distrib 5.1.38, for unknown-linux-gnu (x86_64) using  EditLine wrapper

mysql> show variables like "character_set_database";
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| character_set_database | utf8  |
+------------------------+-------+
1 row in set (0.00 sec)

mysql> show variables like "collation_database";
+--------------------+----------+
| Variable_name      | Value    |
+--------------------+----------+
| collation_database | utf8_bin |
+--------------------+----------+
1 row in set (0.00 sec)

[root@zephyrnode /domain/rails/testapp ]# ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux]

[root@zephyrnode /domain/rails/testapp ]# rails -v
Rails 2.3.4

[root@zephyrnode /domain/rails/testapp ]# gem -v
1.3.5

[root@zephyrnode /domain/rails/testapp ]# gem list

*** LOCAL GEMS ***

actionmailer (2.3.4)
actionpack (2.3.4)
activerecord (2.3.4)
activeresource (2.3.4)
activesupport (2.3.4)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
fastthread (1.0.7)
gem_plugin (0.2.3)
mysql (2.8.1)
rack (1.0.0)
rails (2.3.4)
rake (0.8.7)
rubygems-update (1.3.5)

我的数据库.yml:

development:
  adapter: mysql
  encoding: utf8
  collation: utf8_bin
  reconnect: false
  database: testapp_development
  pool: 5
  username: root
  password: rootpass
  socket: /var/run/mysqld/mysqld.sock
  host: 127.0.0.1

【问题讨论】:

    标签: mysql ruby-on-rails


    【解决方案1】:

    您是否尝试过不指定排序规则?我正在使用 utf8 为我的 MySQL 数据库指定编码而不是排序规则,它可以工作。

    【讨论】:

    • 感谢您的回复。我确实尝试过不指定任何一个/或编码和排序规则,但这些排列都不起作用。
    【解决方案2】:

    将您的 database.yml 文件中的排序规则行更改为以下产生 show variables like "collation_server"; 的任何内容。

    那就试试rake RAILS_ENV=development db:create。

    【讨论】:

      猜你喜欢
      • 2023-04-11
      • 2017-03-19
      • 1970-01-01
      • 2011-08-30
      • 2021-09-10
      • 2015-10-09
      • 2016-04-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多