質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Q&A

解決済

2回答

945閲覧

heroku rake db:migrateをするとMysql2::Error: Unsupported charset: '"unicode"'

bohzu13

総合スコア8

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

0グッド

0クリップ

投稿2020/06/24 06:44

##しようとしている事
勉強し出して2ヶ月の初学者になります。
Herokuでデプロイしたい。
Heroku+Rails+MySQL

最初PostgreSQLでしようとしてエラーで動けなくなってMySQLに変えて取り組んでます。

##エラー内容

ターミナルで
heroku run rails db:migrateするとエラーが出ました。

Mysql2::Error: Unsupported charset: '"unicode"'

翻訳
Mysql2 :: Error:サポートされていない文字セット: '"unicode"'

##関連ソース

database.yml

1# MySQL. Versions 5.1.10 and up are supported. 2# 3# Install the MySQL driver 4# gem install mysql2 5# 6# Ensure the MySQL gem is defined in your Gemfile 7# gem 'mysql2' 8# 9# And be sure to use new-style password hashing: 10# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html 11# 12default: &default 13 adapter: mysql2 14 encoding: utf8 15 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 16 username: root 17 password: 18 socket: /tmp/mysql.sock 19 20development: 21 <<: *default 22 database: bicycle2_development 23 24# Warning: The database defined as "test" will be erased and 25# re-generated from your development database when you run "rake". 26# Do not set this db to the same as development or production. 27test: 28 <<: *default 29 database: bicycle2_test 30 31# As with config/secrets.yml, you never want to store sensitive information, 32# like your database password, in your source code. If your source code is 33# ever seen by anyone, they now have access to your database. 34# 35# Instead, provide the password as a unix environment variable when you boot 36# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 37# for a full rundown on how to provide these environment variables in a 38# production deployment. 39# 40# On Heroku and other platform providers, you may have a full connection URL 41# available as an environment variable. For example: 42# 43# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" 44# 45# You can use this database configuration with: 46# 47# production: 48# url: <%= ENV['DATABASE_URL'] %> 49# 50production: 51 <<: *default 52 database: bicycle2_production 53 username: bicycle2 54 password: <%= ENV['BICYCLE2_DATABASE_PASSWORD'] %> 55

##やった事
PostgreSQLのgemの削除
heroku run rake db:migrate:reset

ヒントをいただけると嬉しいです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

データベース接続を環境変数 DATABASE_URL で設定していますか?

参考: Rails Database Connection Behavior | Heroku Dev Center

また、上記の記事より、
Rails の database.yml の設定で、Heroku 向けの環境に該当する
次の項目は設定することができません。

  • adapter
  • database
  • username
  • password
  • host
  • port

上記の記事では、次のような、Heroku 向けの環境に該当する項目の設定例が提示されています

yaml

1production: 2 encoding: utf8 3 pool: 15

また、Clear DB と Rails の場合の公式な手順が次の記事に示されています
Connecting to ClearDB from Heroku using Ruby on Rails on Cedar – ClearDB

そして、念のため encodingunicode に設定されていないかも確認しましょう
encoding は次のいずれかである必要があります:
MySQL :: MySQL 5.7 Reference Manual :: 10.10 Supported Character Sets and Collations

リンクは MySQL 5.7 のためのものです、利用している MySQL のバージョンに注意してください

database.yml の詳細については次を参照してください
参考: Configuring Rails Applications — Ruby on Rails Guides

投稿2020/07/24 16:47

y_shinoda

総合スコア3272

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

自己解決

わからないためPostgreSQLでできる様に再チャレンジする事にしました。

投稿2020/06/25 07:08

bohzu13

総合スコア8

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問