私の歴史と今

振り返ると恥ずかしくなるのが私の歴史。だけどそのときは真面目に書いていた訳でね。そんな今の私を書いていく。

Rails4プロジェクト作成の続き

MySQLの設定を続ける。

以下をインストールしてある前提。

  1. mysql-5.6.13-osx10.7-x86_64.pkg
  2. MySQLStartupItem.pkg
  3. MySQL.prefPane

PATH設定

kenmochi-no-MacBook-Pro:bin junya$ vi ~/.bash_profile 
kenmochi-no-MacBook-Pro:bin junya$ . ~/.bash_profile 
kenmochi-no-MacBook-Pro:bin junya$ cat ~/.bash_profile 
eval "$(rbenv init -)"

export PATH=$PATH:/usr/local/mysql/bin

rootのパスワードをrootに設定。
プロジェクト用のユーザを作成。

kenmochi-no-MacBook-Pro:bin junya$ mysqladmin -u root password 'root'
kenmochi-no-MacBook-Pro:bin junya$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.13 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.01 sec)

mysql> create user 'imacros-skill'@'localhost' identified by 'imacros-skill';
Query OK, 0 rows affected (0.01 sec)

mysql> grant all privileges on imacros_skill_development.* to 'imacros-skill'@'localhost';
Query OK, 0 rows affected (0.01 sec)

mysql> grant all privileges on imacros_skill_test.* to 'imacros-skill'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

database.ymlの編集

development:
  adapter: mysql2
  encoding: utf8
  database: imacros_skill_development
  pool: 5
  username: imacros-skill
  password: imacros-skill
  host: localhost

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  encoding: utf8
  database: imacros_skill_test
  pool: 5
  username: imacros-skill
  password: imacros-skill
  host: localhost
kenmochi-no-MacBook-Pro:imacros-skill junya$ bundle exec rake db:create --trace
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
kenmochi-no-MacBook-Pro:imacros-skill junya$ mysql -u root -proot
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 26
Server version: 5.6.13 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
mysql> show databases;
+---------------------------+
| Database                  |
+---------------------------+
| information_schema        |
| imacros_skill_development |
| imacros_skill_test        |
| mysql                     |
| performance_schema        |
| test                      |
+---------------------------+
7 rows in set (0.00 sec)

もう一度webrickを起動してトップ画面を表示してみる。

kenmochi-no-MacBook-Pro:imacros-skill junya$ bundle exec rails s
=> Booting WEBrick
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2013-08-02 23:48:10] INFO  WEBrick 1.3.1
[2013-08-02 23:48:10] INFO  ruby 2.0.0 (2013-06-27) [x86_64-darwin12.4.0]
[2013-08-02 23:48:10] INFO  WEBrick::HTTPServer#start: pid=85151 port=3000kenmochi-no-MacBook-Pro:imacros-skill junya$ bundle exec rails s
=> Booting WEBrick
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2013-08-02 23:48:10] INFO  WEBrick 1.3.1
[2013-08-02 23:48:10] INFO  ruby 2.0.0 (2013-06-27) [x86_64-darwin12.4.0]
[2013-08-02 23:48:10] INFO  WEBrick::HTTPServer#start: pid=85151 port=3000


Started GET "/" for 127.0.0.1 at 2013-08-02 23:48:20 +0900
Processing by Rails::WelcomeController#index as HTML
  Rendered vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/templates/rails/welcome/index.html.erb (2.0ms)
Completed 200 OK in 27ms (Views: 10.7ms | ActiveRecord: 0.0ms)


Started GET "/rails/info/properties" for 127.0.0.1 at 2013-08-02 23:48:23 +0900
Processing by Rails::InfoController#properties as */*
  Rendered vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/templates/rails/info/properties.html.erb (0.4ms)
Completed 200 OK in 15ms (Views: 9.5ms | ActiveRecord: 0.6ms)

OK!!!