回答編集履歴

1

別の助言が必要だったみたいなので追記

2019/11/01 05:35

投稿

kuraudo
kuraudo

スコア137

test CHANGED
@@ -9,3 +9,105 @@
9
9
 
10
10
 
11
11
  (ちなみにこれだけだと次にPendingMigrationErrorが出たりすると思うので `rails db:migrate` もしておくとすんなり通ると思います。)
12
+
13
+
14
+
15
+ 【追記】
16
+
17
+
18
+
19
+ https://www.javadrive.jp/rails/model/index2.html
20
+
21
+
22
+
23
+ 上記のサイトから設定ファイルを拾ってきたんですが、例えば以下のようにして `rails db:create` してからmysql接続しようとしたら上手く行きますかね?
24
+
25
+
26
+
27
+ ```
28
+
29
+ # MySQL. Versions 4.1 and 5.0 are recommended.
30
+
31
+ #
32
+
33
+ # Install the MYSQL driver
34
+
35
+ # gem install mysql2
36
+
37
+ #
38
+
39
+ # Ensure the MySQL gem is defined in your Gemfile
40
+
41
+ # gem 'mysql2'
42
+
43
+ #
44
+
45
+ # And be sure to use new-style password hashing:
46
+
47
+ # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
48
+
49
+ development:
50
+
51
+ adapter: mysql2
52
+
53
+ encoding: utf8
54
+
55
+ reconnect: false
56
+
57
+ database: sample_mysql_development
58
+
59
+ pool: 5
60
+
61
+ username: root
62
+
63
+ password:
64
+
65
+ host: localhost
66
+
67
+
68
+
69
+ # Warning: The database defined as "test" will be erased and
70
+
71
+ # re-generated from your development database when you run "rake".
72
+
73
+ # Do not set this db to the same as development or production.
74
+
75
+ test:
76
+
77
+ adapter: mysql2
78
+
79
+ encoding: utf8
80
+
81
+ reconnect: false
82
+
83
+ database: sample_mysql_test
84
+
85
+ pool: 5
86
+
87
+ username: root
88
+
89
+ password:
90
+
91
+ host: localhost
92
+
93
+
94
+
95
+ production:
96
+
97
+ adapter: mysql2
98
+
99
+ encoding: utf8
100
+
101
+ reconnect: false
102
+
103
+ database: sample_mysql_production
104
+
105
+ pool: 5
106
+
107
+ username: root
108
+
109
+ password:
110
+
111
+ host: localhost
112
+
113
+ ```