我在dotinstall的Heroku入门课程中遇到了巨大的挑战
创建第05个Rails应用程序 | Heroku入门- 如果你想学编程, 就选Dotinstall
Heroku命令
无法安装heroku命令
无法通过访问https://toolbelt.heroku.com 来下载,页面陷入了重定向循环,因此只能手动安装。
wget https://toolbelt.heroku.com/install.sh
sh install.sh
echo export PATH=/usr/local/heroku/bin:\$PATH >> ~/.zshrc
source ~/.zshrc
heroku login
Enter your Heroku credentials.
Email: tukiyo3@gmail.com
Password (typing will be hidden):
Found the following SSH public keys:
1) id_boot2docker.pub
2) id_rsa.pub
Which would you like to use with your Heroku account? 2
Uploading SSH public key /Users/owner/.ssh/id_rsa.pub... done
Authentication successful.
轨道交通
rails new mymemo -d postgresql
cd mymemo
- # gem 'therubyracer', platforms: :ruby
+ gem 'therubyracer', platforms: :ruby
postgresql – PostgreSQL
没有pg_config
没有pg_config文件
- postgresql-devel に pg_configが含まれています。
yum install -y postgresql-server postgresql-devel
无法启动postgresql
- initdbするようにメッセージが表示されているので従う。
service postgresql initdb
在启动Docker中的PostgreSQL时遇到错误。
- 無視
service postgresql start
Starting postgresql service: /etc/init.d/postgresql: line 114: echo: write error: Permission denied
无法连接到PostgreSQL的rails s。
rails s
http://localhost:3000 にアクセスすると以下エラー

- postgresqlに接続できていないことだと思うので以下実施
我尝试学习Postgres。
对于一些预先知识
su – postgresしてからpsqlでpostgresに接続できる。
\l データベース一覧表示
\du ユーザ一覧表示
\h SQLコマンド一覧表示。わりと役立つ
\q quit
postgresユーザにてcreateuser mymemoでアカウント作成できる。
use databaseに対応するのは\connect DBNAME
※ 下面的内容本次不需要。
su - postgres
psql
create role mymemo with login;
create user mymemo with password 'mymemo';
create database mymemo with owner mymemo;
\l
\q
- パスワードの変更はalter user mymemo with password ‘newpass’
使用”psql -U 用户名”命令无法连接到Postgres数据库。
$ psql -U mymemo
psql: FATAL: Ident authentication failed for user "mymemo"
- local all all ident
+ local all all trust
service postgresql restart
psql -U mymemo
- 接続できることを確認。
如果要通过root进行psql连接的话
psql -U postgresするのが流儀っぽいが、psqlだけで接続したい場合。
psqlコマンドだけだと、usernameとdatabase名に現在ログイン中のユーザ名が使われる。
$ createuser root
Shall the new role be a superuser? (y/n) y
无法创建数据库

$ bin/rake db:create db:migrate
PG::InvalidParameterValue: 错误:新编码(UTF8)与模板数据库的编码(SQL_ASCII)不兼容
提示:使用与模板数据库相同的编码,或使用template0作为模板。
:CREATE DATABASE “mymemo_development” ENCODING = ‘unicode’
development:
<<: *default
database: mymemo_development
+ template: template0
只需要一种选择参考。
我终于成功启动了Rails服务器。
rails s
