体重133キロからのプログラミング

体重はちょっと減って今125キロです。

人生14日目

開発環境

以前からアイデアを温めていたウェブアプリの開発を始めるべく、環境をセットアップした。   死ぬほどハマった。
もうやりたくねえ。
一応Rails + mySQL、Gitを使える環境を整えた。
途中メンターの前原さんにはかなりお世話になったのでお礼を言いたい。うんこ。

RailsSQL連携しようとしたらインストールでハマった

以下で解決
Railsにmysql2をbundle installする際、詰まったメモ(Ubuntu18.04) - Qiita

$ bundle install
Failed to load /home/peinorou/.gemrc, (<unknown>): mapping values are not allowed in this context at line 3 column 8
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using bundler 2.0.2
Fetching mysql2 0.5.2
Installing mysql2 0.5.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/peinorou/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.5.2/ext/mysql2
/home/peinorou/.rbenv/versions/2.4.1/bin/ruby -r ./siteconf20190730-13738-yfqw90.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
checking for -lmysqlclient... no
-----
mysql client is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install
mysql-devel', and try again.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/peinorou/.rbenv/versions/2.4.1/bin/$(RUBY_BASE_NAME)
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysql-config
    --without-mysql-config
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysqlclientlib
    --without-mysqlclientlib

To see why this extension failed to compile, please check the mkmf.log which can be found
here:

/home/peinorou/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/mysql2-0.5.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/home/peinorou/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.5.2 for inspection.
Results logged to
/home/peinorou/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/mysql2-0.5.2/gem_make.out

An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds
before bundling.

In Gemfile:
  mysql2

上記エラーでハマったが

$ sudo apt-get install libmysqlclient-dev

須藤さんにお願いしたらいけた

SQLの初期パスワードが不明でログインできなくてハマった

$ mysql -u root -p
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
$ sudo mysql
[sudo] peinorou のパスワード: 
Welcome to the MySQL monitor.

以下のページを参考にして、以降は須藤さんにお願いしなくてよくなった。

その他参考にしたページ

Mysql 5.7* パスワードをPolicyに合わせるとめんどくさい件について - Qiita

RailsのDBを(初めから| |後から)MySQLに変更する - Qiita

MySQL5.7 root ユーザのパスワードとログイン - Qiita