2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQL for mac エラー編

Last updated at Posted at 2020-03-20

MySQLをインストールする手順は下記を参考に導入しました
Mac へ MySQL を Homebrew でインストールする手順

動作確認

  • 動作確認をすると接続エラーが!
$ mysql -uroot -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

どうやらファイルが/tmp/mysql.sockファイルがないためらしいのでファイルを作成する

$ sudo touch /tmp/mysql.sock
# 所有権限を変更する
$ sudo chown -R _mysql:_mysql /usr/local/var/mysql
  • MySQLサーバーを再起動
$ sudo mysql.server start
... ERROR! The server quit without updating PID file (/usr/local/var/mysql/xxxxx.local.pid).
  • またもファイルがないと怒られるのでファイルを作成する
$ sudo touch /usr/local/var/mysql/xxxxx.local.pid
$ sudo mysql.server start!
Starting MySQL
. SUCCESS!
  • 改めて動作確認
$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19 Homebrew

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

ドライバ接続エラー

Unable to load authentication plugin 'caching_sha2_password'.

  • my.confに下記を追加
/usr/local/etc/my.conf
default_authentication_plugin=mysql_native_password
# サーバー再起動
$ sudo mysql.server restart
# ログイン
$ mysql -u root -p
# ユーザーを作成(mysql_native_passwordで作成される)
mysql> CREATE USER 'user_name' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user from mysql.user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | user_name        |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
+-----------+------------------+
5 rows in set (0.01 sec)

persistent-mysqlパッケージインストール時のエラー

  • 'pcre.h' file not foundこんなエラーが出たのでpcreをインストール
pcre-light        > /private/var/folders/73/b39jpnl178xb4sgf8wm2n0yc0000gn/T/stack-13f48f3d3c1d2941/pcre-light-0.4.1.0/Base.hsc:103:10: fatal error: 'pcre.h' file not found
pcre-light        > #include <pcre.h>
pcre-light        >          ^~~~~~~~
# ↑こんなエラー出たのでpcreをインストール
$ brew install pcre
  • 再度ビルドチャレンジするも再びエラーに見舞われる
$ stack build
# こんなエラー
mysql             > Configuring mysql-0.1.7...
mysql             > setup: Missing dependencies on foreign libraries:
mysql             > * Missing (or bad) C libraries: ssl, crypto
mysql             > This problem can usually be solved by installing the system packages that
mysql             > provide these libraries (you may need the "-dev" versions). If the libraries
mysql             > are already installed but in a non-standard location then you can use the
mysql             > flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are.If
mysql             > the library files do exist, it may contain errors that are caught by the C
mysql             > compiler at the preprocessing stage. In this case you can re-run configure
mysql             > with the verbosity flag -v3 to see the error messages.
  • Cのライブラリがないか、パスが間違ってるんじゃないかというエラーメッセージが出ている
# ライブラリをインストール
$ brew install icu4c
Warning: icu4c 64.2 is already installed and up-to-date
To reinstall 64.2, run `brew reinstall icu4c`
$ brew install openssl
Updating Homebrew...
Warning: openssl@1.1 1.1.1d is already installed and up-to-date
To reinstall 1.1.1d, run `brew reinstall openssl@1.1`
# 両方ともインストールされていました
  • Cライブラリのパスを設定
~/.stack/config.yaml
extra-include-dirs:
- /usr/local/opt/icu4c/include
- /usr/local/opt/openssl/include

extra-lib-dirs:
- /usr/local/opt/icu4c/lib
- /usr/local/opt/openssl/lib
  • 再度ビルドチャレンジ
$ stack build
> build (lib + exe)

参考
Aelve Guide | Haskell

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?