MySQL エラーばっかで起動できない( 8系がダメだったので5.6で )

時々MySQL関連のエラーが起こるので解決するに至った情報をまとめました

MySQLはver.8系も出ていますが、データベースクライアントのsequel proが対応していないのでver.5.6にしてます
ちなみに僕は8系でインストールしてデータベースクライアントが対応してないのを知ってver.5.6に変更しました

なので、最初のところは8系の説明で、後半は5.6になってます
ややこしいですが、将来ぞぶんがまた困った時のためなのであしからず

MySQL ver: 5.6
homebrew ver : 1.7.0

 

※MySQL ver. 8系はここから

# 以下を実行
$ mysql_secure_installation

# パスワードを入力すると

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
 ... Failed! Error: Your password does not satisfy the current policy requirements

が表示される

passwordは何も設定していなかったので私はそのままエンター

$ mysql -h localhost -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 8.0.11 Homebrew

Copyright (c) 2000, 2018, 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.

調べてみたところ[ validate password plugin ]が悪さをしているみたいなので削除する

mysql> uninstall plugin validate_password;
Query OK, 0 rows affected, 1 warning (0.14 sec)

もう一回ターミナルへ戻って

$ mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file


# パスワードの長さ設定。開発用なので0で対応

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0  
Please set the password for root here.

New password: 

Re-enter new password: 

Estimated strength of the password: 50 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

通った!

ただし

※MySQL5.6はここから

$ sudo mysql.server start
Starting MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/hiyashikyuri.pid).

となるので、以下のコードからプロセスを出して

$  ps -ef | grep mysql | grep -v grep
# 何個か表示される

$  sudo kill -9 PID

上のやつを消してやることで

$ sudo mysql.server start
Starting MySQL
.2018-07-18T06:15:02.6NZ mysqld_safe A mysqld process with pid=57405 is already running. Aborting!!
 SUCCESS! 

動きました!

参考にしたサイト

MySQL8.0をmacOSにインストールする方法
MYSQL起動時にエラーが発生

angularjs 整数のみ入力可のディレクティブ

angularjsを触ることになって、タイトルのディレクティブがなか中見つからなたったのでシェアします

小数点、マイナス入力ができないです

// js file
var app = angular.module('app', []);

app.directive('numbersOnly', function () {
    return {
        require: 'ngModel',
        link: function (scope, element, attr, ngModelCtrl) {
            function fromUser(text) {
                if (text) {
                    var transformedInput = text.replace(/[^0-9]/g, '');

                    if (transformedInput !== text) {
                        ngModelCtrl.$setViewValue(transformedInput);
                        ngModelCtrl.$render();
                    }
                    return transformedInput;
                }
                return undefined;
            }            
            ngModelCtrl.$parsers.push(fromUser);
        }
    };
});

// html file
<div ng-app="app" class="container">
  
  <p>Demo of AngularJS Numbers Only Directive</p>
  
  <p>Input below will accept only numbers.</p>

  <p><input type="text" ng-model="val" numbers-only class="form-control" /></p>
  
</div>

参考にした記事

AngularJS Numbers Only Directive

ターミナルからSQliteを操作する方法

久しぶりにrails関連の仕事があったので、SQliteで使ったコマンドをまとめてみました

ちなみにrailsでは

$ rails db

のコマンドで入れるようです

# テーブル一覧の表示
sqlite> .tables

# テーブルのカラムを表示
.schema tablename

# テーブルのデータ一覧
SELECT * FROM tablename;

参考にした記事
How to list the tables in an SQLite database file that was opened with ATTACH?

mac OS High Sierraでvirtualboxをインストールできないときの対処法

解決策はセキュリティとプライバシーのところへ行き、アプリを許可することでインストールすることができます

詳しくは参考リンクでお願いします
とても簡単です

 

参考にした記事

VirtualBox installation fails on macOS High Sierra 10.13 #417

新しいパソコンにしたらRmagick関連のエラー発生

新しいパソコンにしたらRmagick関連のエラーがまた出て来ました

最近Python、Javaらへんばっかだったのでrailsのエラーは精神的になんか来ます。。

こちらがエラー文


$  gem install rmagick -v '2.16.0'
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

    current directory: /Users/hiyashikyuri/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0/ext/RMagick
/Users/hiyashikyuri/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20180315-30193-14x1r2g.rb extconf.rb
checking for clang... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.16.0. Can't find MagickWand.h.
*** 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=/Users/hiyashikyuri/.rbenv/versions/2.3.1/bin/$(RUBY_BASE_NAME)

解決策

$ brew uninstall imagemagick
$ brew install imagemagick@6
$ brew link --force imagemagick@6
$ echo 'export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"' >> ~/.bash_profile

$ sudo gem install rmagick -v 2.16.0
Password:
Building native extensions.  This could take a while...
Successfully installed rmagick-2.16.0
Parsing documentation for rmagick-2.16.0
Installing ri documentation for rmagick-2.16.0
Done installing documentation for rmagick after 5 seconds
1 gem installed

で問題なく通りました!

参考にした記事

MacOS Sierra で gem install rmagick が失敗する
Ruby gem rmagick won’t install on Mac OS X

Nativescript BarcodeScanner aotコンパイル時のエラー対処法

リリースビルドを作成中にこのエラーに遭遇しました
tsconfigやら何やらを修正してみたりしたのでかれこれ1日ぐらいかかってしまいました

リリースビルドはターミナルで以下のコードを実行

$ tns build android --bundle --env.uglify --env.aot --env.snapshot --release 
--key-store-path ~/path/to/tj-vantoll.jks
--key-store-password my-very-secure-password
--key-store-alias PokemonTypes
--key-store-alias-password my-very-secure-password
--copy-to android.apk

リリースビルド後にBarcode scannerでQRコード読み込み機能を起動させたところ
こんなエラーが発生

TypeError: t is not a constructor

該当ソース
こちらのコードから

export class ScanComponent implements OnInit {
    constructor(private page: Page,
                private routerExtensions: RouterExtensions,
                private  barcodeScanner:  BarcodeScanner, //ここ
                private scanService: ScanService,
                private stripe_service: StripeService) {
    }

以下のように変更

export class ScanComponent implements OnInit {

   public barcodeScanner = new  BarcodeScanner(); // ここ

   constructor(private page: Page,
                private routerExtensions: RouterExtensions,                
               private scanService: ScanService,
                private stripe_service: StripeService) {
    }

これでエラーは解決しました

参考にした記事

Error – ctor is not a constructor #318

AOT compatibility #76

ちなみにこちらは参考になりませんでした

NativeScript Webpack 0.9.0—What Changed and How to Upgrade
Style is missing when build with –bundle

Create a Plugin to Display Animated Gif in a NativeScript Image

Nativescript snapshotでリリース版をビルドする方法

主にAndroidを高速化するためにSnapshotで高速化しました

事項するためのコードはこちらです
それぞれのパラメータには各自で記載してください

$ tns build android --bundle --env.uglify --env.aot --env.snapshot --release 
--key-store-path ~/path/to/tj-vantoll.jks
--key-store-password my-very-secure-password
--key-store-alias PokemonTypes
--key-store-alias-password my-very-secure-password
--copy-to android.apk

Androidは結構早くなります

参考にした記事

Using Webpack to Bundle Your Code
8 Steps to Publish Your NativeScript App to the App Stores

Angular Cannot find module ‘webpack/lib/node/NodeTemplatePlugin’

普段使っていないパソコンでプロジェクトをクローン & ランしようとしたらタイトルのエラーが発生

$ ng serve
Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)

解決策は

$ rm package-lock.json
$ rm -rf node_modules
$ npm install
$ ng serve

で動きます

参考にした記事

Cannot find module ‘webpack/lib/node/NodeTemplatePlugin’ using cli 1.1.1 #6641

ng serveでCannot find module ‘webpack/lib/node/NodeTemplatePlugin’が出てきた

Angularを起動させようとしたらまたよくわからないエラーが発生しました

$ ng serve
Cannot find module 'webpack/lib/node/NodeTemplatePlugin'

調べて見ると、こちらのコードを実行すると治るようなので実行したところ
今度は別のエラーが出てきました

$ npm remove webpack -g
$ npm i webpack --save-dev

# エラー発生
$ ng serve
Invalid or unexpected token

念のためnode_modulesを削除して再インストールしたところうまくいきました!

$ rm -rf node_modules/

$ npm install

$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-01-25T03:18:47.656Z                                                          
Hash: 946913dea230b090d975
Time: 73057ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 959 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 584 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 36.4 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 10 MB [initial] [rendered]

webpack: Compiled successfully.


参考にした記事
Error: Cannot find module ‘webpack/lib/node/NodeTemplatePlugin’ #2131

Angular 起動できない (module.js:538 throw err;)

久しぶりにAngularを起動させようとしたらなんかよくわからんエラーが出てきました

$ ng serve
module.js:538
    throw err;
    ^

Error: Cannot find module '@angular-devkit/core'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)

とりあえず解決方法
以下の手順を踏むことで解決できます

#1番目
$ npm update -g @angular/cli

#2番目
package.json の中の "@angular/cli" を少し編集
"devDependencies": {
  "@angular/cli": "1.6.5"  // 1.6.5へ変更
}

#3番目
$ npm install

参考にした記事

Error: Cannot find module ‘@angular-devkit/core’ – after clean install #9307