Mac HomeBrew 安装 mysql
源:http://blog.csdn.net/lkxlaz/article/details/54580735
https://www.cnblogs.com/b-ruce/p/5851662.html
评:
MacHomeBrew安装mysql
在网上看到各种教程,都会出现ERROR2002(HY000):Can'tconnecttolocalMySQLserverthroughsocket'/tmp/mysql.sock'
1.确保环境没有mysql
brewremovemysql
brewcleanup
2.安装
brewinstallmysql
3.启动
brewservicesstartmysql
设置开机启动:launchctlload~/Library/LaunchAgents/homebrew.mxcl.mysql.plist(设置启动的命令可以通过brewinfomysql获得)
4.登录
mysql-uroot
=====
5.
那么我们就按照brew的提示运行mysql_secure_installation,运行后会报错:
>mysql_secure_installation
SecuringtheMySQLserverdeployment.
Enterpasswordforuserroot:
Error:Can'tconnecttolocalMySQLserverthroughsocket'/tmp/mysql.sock'(2)
1
2
3
4
5
6
莫慌,提示说找不到mysql.sock。原因是mysql进程还没启动。
6.启动mysql服务
mysql.serverstart
1
7.再运行
>mysql_secure_installation
1
发现成功执行命令
SecuringtheMySQLserverdeployment.
ConnectingtoMySQLusingablankpassword.
VALIDATEPASSWORDPLUGINcanbeusedtotestpasswords
andimprovesecurity.Itchecksthestrengthofpassword
andallowstheuserstosetonlythosepasswordswhichare
secureenough.WouldyouliketosetupVALIDATEPASSWORDplugin?
Pressy|YforYes,anyotherkeyforNo:y
Therearethreelevelsofpasswordvalidationpolicy:
LOWLength>=8
MEDIUMLength>=8,numeric,mixedcase,andspecialcharacters
STRONGLength>=8,numeric,mixedcase,specialcharactersanddictionaryfile
//这里提示选一个密码强度等级
Pleaseenter0=LOW,1=MEDIUMand2=STRONG:1
Pleasesetthepasswordforroothere.
//然后按照所选的密码强度要求设定密码
Newpassword:
Re-enternewpassword:
Estimatedstrengthofthepassword:50
Doyouwishtocontinuewiththepasswordprovided?(Pressy|YforYes,anyotherkeyforNo):y
...Failed!Error:Yourpassworddoesnotsatisfythecurrentpolicyrequirements
Newpassword:
Re-enternewpassword:
Estimatedstrengthofthepassword:100
Doyouwishtocontinuewiththepasswordprovided?(Pressy|YforYes,anyotherkeyforNo):y
Bydefault,aMySQLinstallationhasananonymoususer,
allowinganyonetologintoMySQLwithouthavingtohave
auseraccountcreatedforthem.Thisisintendedonlyfor
testing,andtomaketheinstallationgoabitsmoother.
Youshouldremovethembeforemovingintoaproduction
environment.
//这里删除默认无密码用户
Removeanonymoususers?(Pressy|YforYes,anyotherkeyforNo):y
Success.
Normally,rootshouldonlybeallowedtoconnectfrom
'localhost'.Thisensuresthatsomeonecannotguessat
therootpasswordfromthenetwork.
//禁止远程root登录,我选的是不禁止。因为我的mac上的数据库不会放到公网上,也不会存什么敏感数据
Disallowrootloginremotely?(Pressy|YforYes,anyotherkeyforNo):no
...skipping.
Bydefault,MySQLcomeswithadatabasenamed'test'that
anyonecanaccess.Thisisalsointendedonlyfortesting,
andshouldberemovedbeforemovingintoaproduction
environment.
//这里删除默认自带的test数据库
Removetestdatabaseandaccesstoit?(Pressy|YforYes,anyotherkeyforNo):y
-Droppingtestdatabase...
Success.
-Removingprivilegesontestdatabase...
Success.
Reloadingtheprivilegetableswillensurethatallchanges
madesofarwilltakeeffectimmediately.
Reloadprivilegetablesnow?(Pressy|YforYes,anyotherkeyforNo):y
Success.
Alldone!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
8.
最后测试一下登陆
>mysql-uroot-p
1
ALLDONE!