時々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起動時にエラーが発生

コメントをどうぞ

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

CAPTCHA