MySQL8.0.12 Zip版 on Windows 10(X86,64‐bit) 環境構築

# ダウンロード
- [MySQL8.0.12](https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.12-winx64.zip)
- [Documentation](https://dev.mysql.com/doc/refman/8.0/en/windows-install-archive.html)

# インストール
- zipファイルを解凍　ex) C:\mysql8

# 初期設定
- 環境変数にPathを追加　ex) C:\mysql8\bin
- dataフォルダの作成　ex) C:\mysql8\data
- my.iniを作成　ex) C:\mysql8\my.ini

```txt:mysql8\my.ini
[mysqld]
basedir = c:\mysql8
datadir = c:\mysql8\data
```

# データベース初期化

> mysqld --initialize --console

```sh
c:\mysql8\bin>mysqld --initialize --console
2018-10-01T17:38:05.633190Z 0 [System] [MY-013169] [Server] c:\mysql8\bin\mysqld.exe (mysqld 8.0.12) initializing of server in progress as process 2428
2018-10-01T17:38:12.827899Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: :a*o!Od!!7hi
2018-10-01T17:38:16.842687Z 0 [System] [MY-013170] [Server] c:\mysql8\bin\mysqld.exe (mysqld 8.0.12) initializing of server has completed
```

- 自動で生成されたパスワードを控えておく

```txt:point
A temporary password is generated for root@localhost: :a*o!Od!!7hi
```

# データベース起動

> mysqld --console

```txt
c:\mysql8\bin>mysqld --console
2018-10-01T17:43:34.056852Z 0 [System] [MY-010116] [Server] c:\mysql8\bin\mysqld.exe (mysqld 8.0.12) starting as process 2028
2018-10-01T17:43:36.157196Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2018-10-01T17:43:36.257167Z 0 [System] [MY-010931] [Server] c:\mysql8\bin\mysqld.exe: ready for connections. Version: '8.0.12'  socket: ''  port: 3306  MySQL Community Server - GPL.
```

# ログイン

> mysql -u root -p

```txt
c:\mysql8\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.12

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.

mysql>
```

# パスワードの変更
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';

```sh
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';
Query OK, 0 rows affected (0.10 sec)
```

# パスワードの確認
> SELECT user,host,authentication_string FROM mysql.user;

```sh
mysql> SELECT user,host,authentication_string FROM mysql.user;
+------------------+-----------+------------------------------------------------------------------------+
| user             | host      | authentication_string                                                  |
+------------------+-----------+------------------------------------------------------------------------+
| mysql.infoschema | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.session    | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.sys        | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| root             | localhost | $A$005$%lLRo╔%wyr%╝║xS>:{Hvmr7ljF9sw/YlIhE5N/eoQojljWwslT6zWhT3TRYMg9 |
+------------------+-----------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)
```

# データベース停止

> mysqladmin shutdown -u root -p

```txt
c:\mysql8\bin>mysqladmin shutdown -u root -p
Enter password: *****
```

```txt:停止メッセージ
2018-10-01T18:23:27.309582Z 12 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.12).
2018-10-01T18:23:27.317300Z 0 [System] [MY-013105] [Server] c:\mysql8\bin\mysqld.exe: Normal shutdown.
2018-10-01T18:23:28.547979Z 0 [System] [MY-010910] [Server] c:\mysql8\bin\mysqld.exe: Shutdown complete (mysqld 8.0.12) MySQL Community Server - GPL.
```

# MySQL5.7との違い
- my-default.iniが無かった

# 参考リンク
- [MySQL5.7.10 Zip版 on Windows 10(X86,64‐bit) 環境構築](https://qiita.com/sireline/items/0c2d7d308d3c9722e48d)