mysqlが正しく起動しなくなった時

5.7が入っていた環境に8.0をインストールした場合に発生するらしい

2019-09-15T08:27:16.967577Z 0 [System] [MY-010116] [Server] /usr/local/opt/mysql/bin/mysqld (mysqld 8.0.17) starting as process 33650

2019-09-15T08:27:16.973105Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive

2019-09-15T08:27:17.111260Z 1 [ERROR] [MY-012526] [InnoDB] Upgrade after a crash is not supported. This redo log was created with MySQL 5.7.10. Please follow the instructions at http://dev.mysql.com/doc/refman/8.0/en/upgrading.html

2019-09-15T08:27:16.984522Z 1 [System] [MY-011012] [Server] Starting upgrade of data directory.

一旦、すべて削除する。
必要ならバックアップを取ること。

$ brew uninstall mysql

brew uninstall mysql では削除できないファイル群を削除します。
$ sudo rm -rf /usr/local/Cellar/mysql*
$ sudo rm -rf /usr/local/bin/mysql*
$ sudo rm -rf /usr/local/var/mysql*
$ sudo rm -rf /usr/local/etc/my.cnf
$ sudo rm -rf /usr/local/share/mysql*
$ sudo rm -rf /usr/local/opt/mysql
$ sudo rm -rf /usr/local/mysql
$ sudo rm -rf /Library/StartupItems/MYSQL
$ sudo rm -rf /Library/PreferencePanes/MySQL.prefPane
$ sudo rm -rf /Library/Receipts/mysql-.pkg
$ sudo rm -rf /usr/local/Library/LinkedKegs/mysql 

必要なバージョンをインストールし直す。
$ brew install mysql@5.7

パスを通す
$ echo ‘export PATH=”/usr/local/opt/mysql@5.7/bin:$PATH”‘ >> ~/.bash_profile
$ source ~/.bash_profile
$ mysql.server start

Mac上でlaravelを動かす

サボって、EC2のサーバーにいちいちファイルをアップロード動かしてましたが、エラーが解決できず面倒になってきたので、ローカルで動かすことにする。
でも、さぼって、vagrant は使わずに、直にnginxを動かす。

$ brew install nginx
$ mkdir -p ~/Library/LaunchAgents
$ cp /usr/local/opt/php@7.2/homebrew.mxcl.php@7.2.plist ~/Library/LaunchAgents/
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php@7.2.plist

$ sudo vi /usr/local/etc/nginx/nginx.conf


        listen       8080;
        server_name  localhost;

        location / {
            #root   html;
            root   ドキュメントルート;
            index  index.php index.html index.htm;
        }
        location ~ \.php$ {
            root ドキュメントルート;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

$ sudo nginx -s reload

nginx.confのlistenとserver_nameの通りにブラウザで開く。

http://localhost:8080/index.php

なぜか、index.php付けないと動かず

mysqlもインストールします。
$ brew install mysql
$ brew services start mysql

proc_open(): fork failed – Cannot allocate memory

ec2上で、laravelプロジェクト作ろうとしたら、メモリエラー?

$ sudo composer create-project –prefer-dist laravel/laravel sitename 5.8
Installing laravel/laravel (v5.8.0)

  • Installing laravel/laravel (v5.8.0): Loading from cache
    Created project in companylist

@php -r “file_exists(‘.env’) || copy(‘.env.example’, ‘.env’);”
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 80 installs, 0 updates, 0 removals

  • Installing symfony/polyfill-ctype (v1.12.0): Downloading (100%)
    The following exception is caused by a lack of memory or swap, or not having swap configured
    Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details

PHP Warning: proc_open(): fork failed – Cannot allocate memory in phar:///usr/bin/composer/vendor/symfony/console/Application.php on line 952

Warning: proc_open(): fork failed – Cannot allocate memory in phar:///usr/bin/composer/vendor/symfony/console/Application.php on line 952

[ErrorException]
proc_open(): fork failed – Cannot allocate memory

create-project [-s|–stability STABILITY] [–prefer-source] [–prefer-dist] [–repository REPOSITORY] [–repository-url REPOSITORY-URL] [–dev] [–no-dev] [–no-custom-installers] [–no-scripts] [–no-progress] [–no-secure-http] [–keep-vcs] [–remove-vcs] [–no-install] [–ignore-platform-reqs] [–] [] [] []

swapがない?

$free -m

              total        used        free      shared  buff/cache   available

Mem:            983         272         624           0          86         588

Swap:             0           0           0

$ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
$ sudo /sbin/mkswap /var/swap.1
$ sudo /sbin/swapon /var/swap.1

foliumを使う <準備編>

会社のMotionBoardで地図にデータをマッピングしようと思ったら、データ件数の制限に引っかかって表示出来ない。

自前でやろうと調べているとfoliumというのがあるらしい。
会社ではpipが動かないので、自宅でモジュールをダウンロードして持っていくことに。

$ pip download -d src –no-binary :all: folium

でカレントディレクトリにsrcフォルダが作られて、一式ダウンロードされます。

さて、会社でうまくインストールできるか。

[pyenv] zipimport.ZipImportError: can’t decompress data; zlib not available

会社でpipが使えないので、家でダウンロードして、モジュールを持っていくことに。
まずは、会社のpythonとバージョンを合わせます。


$ pyenv install 3.7.3
python-build: use openssl 1.0 from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.3.tar.xz...
-> https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
Installing Python-3.7.3...
python-build: use readline from homebrew

BUILD FAILED (OS X 10.14.6 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085
Results logged to /var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085.log

Last 10 log lines:
  File "/private/var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085/Python-3.7.3/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/private/var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085/Python-3.7.3/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/private/var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085/Python-3.7.3/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/private/var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907090613.22085/Python-3.7.3/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip._internal
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1

というエラーが出ました。

Mojave用のmacOS SDK headerが入っていないのが原因のようです。


$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Password:
installer: Package name is macOS_SDK_headers_for_macOS_10.14
installer: Installing at base path /
installer: The install was successful.

$ pyenv install 3.7.3
python-build: use openssl 1.0 from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.3.tar.xz...
-> https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
Installing Python-3.7.3...
python-build: use readline from homebrew
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 10.14.6 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907092313.37137
Results logged to /var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/python-build.20190907092313.37137.log

Last 10 log lines:
            install|*) ensurepip="" ;; \
        esac; \
         ./python.exe -E -m ensurepip \
            $ensurepip --root=/ ; \
    fi
Looking in links: /var/folders/tp/7ck2hmbd3hd29wrpwqfbjbz00000gn/T/tmp5xwqmmtv
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.0.3 setuptools-40.8.0

うまくいきました。