Mac 安装 mysql8.1.2, 且支持客户端登录
Mac 安装 mysql8 版本会遇到不少的坑, 大家可以用如下方式解决:
1, 用 brew 安装最新版本的 MySQL, 我安装的时候还是 8.1.2
brew install MySQL
2, 开启 MySQL 服务
brew services start MySQL
3, 安装安全插件, 即为 MySQL 的 root 帐号生成密码mysql_secure_installation
3.1
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.VALIDATE PASSWORD COMPONENT can be used to test passwords
andimprove security.Itchecks the strengthofpassword
andallows the users tosetonly those passwords which are
secure enough.Wouldyou like to setup VALIDATE PASSWORD component?
Pressy|YforYes,any other keyforNo:
此时选 y, 开启密码组件3.2
Thereare three levelsofpassword validation policy:
LOWLength>=8
MEDIUMLength>=8,numeric,mixedcase,andspecial characters
STRONGLength>=8,numeric,mixedcase,special charactersanddictionary file
Pleaseenter0=LOW,1=MEDIUMand2=STRONG:
这一步是选择安全等级, 按需选择, 我建议选择 0
3.3
Please set the password for root here.Newpassword:
Re-enternewpassword:
这一步是输入密码和确认密码3.4
Doyou wish tocontinuewiththe password provided?(Pressy|YforYes,any other keyforNo):
输入 y, 确认提交密码3.5
Bydefault,aMySQLinstallation has an anonymous user,
allowing anyone to logintoMySQLwithout having to have
a user account createdforthem.Thisisintended onlyfor
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) :
输入 y, 删除匿名用户3.6
Normally,root should only be allowed to connectfrom
'localhost'.Thisensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) :
如果要禁止 root 远程登录, 可以选 yes, 否则选 no. 本地的话, 我建议选 no 吧.3.7
Bydefault,MySQLcomeswitha database named'test'that
anyone can access.Thisisalso intended onlyfortesting,
andshould be removed before movingintoa production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) :
选 y, 删除 test 数据库, 我们自己建其他库就是了3.8
Reloadingthe privilege tables willensurethat all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
选 y 就是了
好了, 以上操作完之后, 就为 root 创建了一个密码了.
4, 此时你兴致勃勃的去 Sequal pro 登录 (或其他客户端), 此时会提示
Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/MySQL/lib/plugin/caching_sha2_password.so, 2): image not found
说明客户端不支持这种加密方式, 因为默认生成的 root 的密码是用 caching_sha2_password 插件加密的. 而客户端找不到 caching_sha2_password 插件, 于是登录不上.
4.1 我们先通过终端输入: MySQL -u root -p 登录 MySQL, 然后 MySQL>use MySQL
4.2 CREATE USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY '12345678'(按照配置的安全等级来, 我配置的 0, 所以只要满足 8 位以上就可以了);
4.3 grant all on . to test@'%'; 需要给 test 帐号授权, 否则 test 帐号没任何权限.
好了, 以上操作完之后, 客户端就可以登录 MySQL 了.
如在安装过程中遇到问题, 请联系我 (qq:378439929)
本文版权归逍遥 jc 所有, 转载请注明来源, 谢谢合作.
来源: http://www.jianshu.com/p/428174574190