【MySQL】インストール

https://www.mysql.com/jp/

#ダウンロード#

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/9c3bab17-03be-076c-13c9-94de56939801.png)

したのほうへ


![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/c8c7944f-11bc-ab1b-def8-eb308c31854f.png)

MySQL Community (GPL) Downloads »
↑
をクリック

MySQL Community Downloads
＞MySQL Community Server

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/9023b54b-8a2f-806e-0449-c1c7b91c7303.png)

Go to Download page

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/330abd4e-3bdc-951d-4ba2-d92f74cdc447.png)

mysql-installer-community-8.0.21.0.msi
↑
こちらをインストール


No thanks , just start my download.


インストール時に一緒にいろいろとインストールできる場合もある
「Excute」を実行すると、チェックされる。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/83c47014-a8ff-3bb6-cc49-442030042571.png)




------

#インストールを続ける#

MySQL Installerを起動する


![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/1dada9bd-2987-3926-3725-748a8a1025cb.png)

Microsoft Visual C++n2015-2019 が必要
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/5b182d5f-203d-5fac-4e7b-61f92a0e3fb6.png)


Microsoft Visual C++n2015-2019 インストール後

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/1584bbcd-60ff-88c3-a13c-b9cbaa8b7197.png)


![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/16536ef3-a9bd-ab02-047a-10d99898f146.png)




![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/b1cd5032-1826-ec44-81a0-f797bc6cd2b9.png)

Visual Studioインストール
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/4303e6f2-1adc-2599-4249-f46168bb65ff.png)

check Requirements
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/1c339c05-3ea0-0711-52ed-8223a5585054.png)

 Installation

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/672511bc-8640-b984-4c97-744a792ccc46.png)
※2021/1/29 tatemono
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/a826ddaa-7fc0-61df-ccad-cdbe2984c7a2.png)

※ちょっと時間がかかるところ。。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/9ad4e436-c7c9-5c1d-821a-7f947c0fd22b.png)

※2021/1/29 tatemono
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/6d26961e-cd0b-7904-2a73-5c1a3b455ee4.png)




![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/ab7fe6ab-4acb-cc1e-9b9a-47433cca6133.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/3de281f1-5dfa-a6fd-3c49-502b8670202b.png)


![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/6a613598-6683-59fd-4682-b5aeb64b5bfa.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/738280f1-c4da-a6d6-a765-522d1b839ea4.png)


![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/82a43bc1-5f39-a9f4-b9f7-d1f95acb6287.png)

↑Windowサービスへの登録

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/bc806390-99c0-c0b4-3a35-f086215ccf41.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/b164364f-fc8f-e313-1fae-69d25151e3f3.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/afc8db33-b008-1c76-0e86-68980b05bd00.png)


connect to server
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/00f3952a-c1c1-54c6-3d72-8971fe7bbb78.png)



----

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/a6bc1c69-4793-8fca-e4d9-00f2d8e6c782.png)

一回、インストーラーを再起動した
※MySQL Installerより、Connector ODBC(x64)をアンインストールする
　（先にアンインストールしないとx84(32bit)がインストールできない）
※Connector ODBC(x84)をMySQL Installerよりインストールする




↓MySQL Installer
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/230606e1-c585-317b-970c-4615e5ee1c7e.png)

----

#ODBCの設定#

```
C:\Windows\SysWOW64\odbcad32.exe
```
をクリックして起動する

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/e37fd348-9177-e4a2-43b5-94c2c12f662d.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/66418c97-4566-bcc9-a3ea-8dc803a9697a.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/1186611d-6577-07e8-a493-729fc30b15e8.png)

↓
あとで、Worldを入れて、再設定した！
（あとで、接続データベースは変更可能。）
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/f54aefa4-08cc-61ec-f1a2-5b7c71304b2b.png)



#サンプルデータベースWorldのセットアップ#

https://dev.mysql.com/doc/index-other.html

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/692785/2a327cec-4f6e-5063-dded-ffcf8c51287a.png)

SOURCE [パス]\world.sql

今回、USBで持ち込んだので

```
SOURCE E:\MySQL_world\world.sql\world.sql
```
と入力。

```
mysql> SHOW databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| world              |
+--------------------+
5 rows in set (0.00 sec)

```

入りました。


#my.iniの文字コード設定#
[client] default-character-set=utf8mb4
[mysql] default-character-set=utf8mb4
[mysqld] character-set-server=utf8mb4


```mysql:mysql
mysql> show variables like "chara%";
+--------------------------+---------------------------------------------------------+
| Variable_name            | Value                                                   |
+--------------------------+---------------------------------------------------------+
| character_set_client     | utf8                                                    |
| character_set_connection | utf8                                                    |
| character_set_database   | utf8mb4                                                 |
| character_set_filesystem | binary                                                  |
| character_set_results    | utf8                                                    |
| character_set_server     | utf8mb4                                                 |
| character_set_system     | utf8                                                    |
| character_sets_dir       | C:\Program Files\MySQL\MySQL Server 5.7\share\charsets\ |
+--------------------------+---------------------------------------------------------+
8 rows in set, 1 warning (0.00 sec)

mysql> show global variables like 'character_set%';
+--------------------------+---------------------------------------------------------+
| Variable_name            | Value                                                   |
+--------------------------+---------------------------------------------------------+
| character_set_client     | utf8mb4                                                 |
| character_set_connection | utf8mb4                                                 |
| character_set_database   | utf8mb4                                                 |
| character_set_filesystem | binary                                                  |
| character_set_results    | utf8mb4                                                 |
| character_set_server     | utf8mb4                                                 |
| character_set_system     | utf8                                                    |
| character_sets_dir       | C:\Program Files\MySQL\MySQL Server 5.7\share\charsets\ |
+--------------------------+---------------------------------------------------------+
8 rows in set, 1 warning (0.00 sec)

```


## my.iniが「上書き禁止」のとき (2021.1.11) ##
(MySQL 8.0）

※コピーして編集
※古いmi.iniを何らかの名前でリネーム
※編集したほうを、my.iniにする
※mySQLを再起動