teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

MySQLのインストール手順を追加

2019/09/19 11:34

投稿

nandymak
nandymak

スコア799

answer CHANGED
@@ -20,4 +20,120 @@
20
20
 
21
21
  ```
22
22
  $ echo $PATH
23
+ ```
24
+ ---
25
+
26
+ 2019/09/19 20:00追記
27
+ ## MySQL@5.6をHomebrewでインストールしてみました。
28
+ ### 現状の確認
29
+ ```bash
30
+ nandymak:~ nandymak$ brew uninstall mariadb
31
+ Error: No such keg: /usr/local/Cellar/mariadb
32
+ nandymak:~ nandymak$ brew list
33
+ cmake graphviz libgcrypt libxmlsec1 p11-kit
34
+ fontconfig gts libgpg-error mpfr pcre
35
+ freetype heroku libidn2 netpbm python
36
+ gcc heroku-node libmpc nettle r
37
+ gd icu4c libpng node readline
38
+ gdbm isl libtasn1 nodebrew sqlite
39
+ gettext jasper libtiff oath-toolkit unbound
40
+ glib jpeg libtool openblas webp
41
+ gmp libevent libunistring openssl wget
42
+ gnutls libffi libxml2 openssl@1.1 xz
43
+ nandymak:~ nandymak$
44
+ ```
45
+ ### MySQL5.6をインストール
46
+ ```bash
47
+ nandymak:~ nandymak$ brew search mysql@5.6
48
+ ==> Formulae
49
+ mysql@5.6
50
+ nandymak:~ nandymak$ brew install mysql@5.6
51
+ Updating Homebrew...
52
+ ==> Auto-updated Homebrew!
53
+ Updated 1 tap (homebrew/core).
54
+ ==> Updated Formulae
55
+ etcd pilosa teleport
56
+
57
+ ==> Downloading https://homebrew.bintray.com/bottles/mysql@5.6-5.6.43.mojave.bottle.1.tar.gz
58
+ ==> Downloading from https://akamai.bintray.com/8d/8d276249e7adf93c716505d9959c690db014693480
59
+ ######################################################################## 100.0%
60
+ ==> Pouring mysql@5.6-5.6.43.mojave.bottle.1.tar.gz
61
+ ==> Caveats
62
+ A "/etc/my.cnf" from another install may interfere with a Homebrew-built
63
+ server starting up correctly.
64
+
65
+ MySQL is configured to only allow connections from localhost by default
66
+
67
+ To connect:
68
+ mysql -uroot
69
+ (途中省略)
70
+ To have launchd start mysql@5.6 now and restart at login:
71
+ brew services start mysql@5.6
72
+ Or, if you don't want/need a background service you can just run:
73
+ /usr/local/opt/mysql@5.6/bin/mysql.server start
74
+ ==> Summary
75
+ ???? /usr/local/Cellar/mysql@5.6/5.6.43: 341 files, 153.6MB
76
+ nandymak:~ nandymak$
77
+ ```
78
+
79
+ ### 動作を確認
80
+ ```bash
81
+ nandymak:~ nandymak$ mysql -uroot
82
+ -bash: mysql: command not found
83
+ nandymak:~ nandymak$ which mysql
84
+ nandymak:~ nandymak$ type mysql
85
+ -bash: type: mysql: not found
86
+ nandymak:~ nandymak$
87
+ ```
88
+ ### PATHを通す
89
+ ```bash
90
+ nandymak:~ nandymak$ echo 'export PATH="/usr/local/opt/mysql@5.6/bin:$PATH"' >> ~/.bash_profile
91
+ nandymak:~ nandymak$ source ~/.bash_profile
92
+ nandymak:~ nandymak$ type
93
+ nandymak:~ nandymak$ mysql
94
+ ERROR 1045 (28000): Access denied for user 'nandymak'@'localhost' (using password: NO)
95
+ nandymak:~ nandymak$ mysql --version
96
+ mysql Ver 14.14 Distrib 5.6.43, for osx10.14 (x86_64) using EditLine wrapper
97
+ ```
98
+ ### 起動する
99
+ ```
100
+ nandymak:~ nandymak$ brew services start mysql@5.6
101
+ ==> Successfully started `mysql@5.6` (label: homebrew.mxcl.mysql@5.6)
102
+ ```
103
+ ### ログインする
104
+ ```bash
105
+ nandymak:~ nandymak$ mysql -uroot -pXXXXXXXX
106
+ Warning: Using a password on the command line interface can be insecure.
107
+ Welcome to the MySQL monitor. Commands end with ; or \g.
108
+ Your MySQL connection id is 27
109
+ Server version: 5.5.5-10.4.6-MariaDB Homebrew
110
+
111
+ Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
112
+
113
+ Oracle is a registered trademark of Oracle Corporation and/or its
114
+ affiliates. Other names may be trademarks of their respective
115
+ owners.
116
+
117
+ Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
118
+
119
+ mysql> quit
120
+ Bye
121
+ nandymak:~ nandymak$
122
+ ```
123
+
124
+ ### my.cnfを確認する。
125
+ ```bash
126
+ nandymak:etc nandymak$ cat /usr/local/etc/my.cnf
127
+ #
128
+ # This group is read both both by the client and the server
129
+ # use it for options that affect everything
130
+ #
131
+ [client-server]
132
+
133
+ #
134
+ # include all files from the config directory
135
+ #
136
+ !includedir /usr/local/etc/my.cnf.d
137
+
138
+ nandymak:etc nandymak$
23
139
  ```