介绍
小编给大家分享一下如何在Mac下搭建MySQL环境,希望大家阅读完这篇文章之后都有所收获、下面让我们一起去探讨吧!
方法一:用dmg镜像安装
1,安装
官网下载好MySQL Mac版安装包,常规步骤安装,安装过程中会出现如下提示:
2019 - 03 - 24 t18:27:31.043133z 1,[注],A temporary password is generated for root@localhost:, TdfRm19 ! o0Xi
其中<代码> TdfRm19 !o0Xi> 代码是初始密码,最好先记住!
2,登陆
在终端命令行登陆mysql:
,美元mysql -u root - p #,输入上述密码即可
如果这一步提示:<代码> bash: mysql:命令没有找到> 代码,执行下面2个命令做个软连接即可:
cd /usr/地方/bin ln -fs /usr/地方/mysql-8.0.11-macos10.13-x86_64/bin/mysql mysql
3,修改密码
在MySQL8.0.4以前,执行<代码>设置密码=密码(& # 39;新密码& # 39;)代码>即可。但新版本不能这样改了,因为密码认证变了。具体步骤可以参考https://blog.csdn.net/yi247630676/article/details/80352655。
方法二:用自制程序进行安装
总所周知,Mac可以利用家酿进行安装管理,十分方便,如果没有安装自制程序,可以点击https://brew。sh/安装。
下面是mysql的安装方式
,美元brew install mysql ,, #,安装指定版本:,brew install mysql@1.1.1
接下来只要等待就可以了,出现下面文字后我们已经很清楚我们需要做什么了:
==在mysql 我们# 39;ve  installed your  MySQL database without a root 密码只用secure it 运行: ,,mysql_secure_installation MySQL is  configured 用only allow connections 得到localhost by 违约 用connect 运行: ,,,mysql -u 根 用have launchd  start mysql 你以及restart at 登录: brew 才能;services  start mysql 或者,if 你不要# 39;t 想要/need a background service 你还要just 运行: mysql.server 才能开始
按说明继续执行,进行初始化操作:
,美元myysql_secure_installation
初始化过程中会有很多问题,以下是具体问题部分,以注释为解释:
Would 你like 用setup VALIDATE PASSWORD 组件? Press y | Y for 是的,,any other key for 没有:,Y ,, # #,回复Y 需要密码8位以上,回复n 则不做限制 从而password validation  component is  not 可用只Proceeding with 从而further steps without 从而组件。 Please set 从而password for  root 这里。 New 密码:,,,# #,设置你的密码 Re-enter new 密码:,,,# #,再次输入你的密码 By 默认情况下,,a MySQL  installation has an anonymous 用户, allowing anyone 用log into  MySQL without having 用 a user  account created  for 他们只却;能够is intended only 测试,以及用make 从而installation go a bit 平滑。 你should remove  them before  moving into a 生产 环境。 Remove anonymous 用户?,(Press y | Y for 是的,,any other key for No),:, Y ,,, # #,是否移除匿名用户。考虑安全我选了y 成功。 通常,root should  only be allowed 用connect 从 & # 39;localhost # 39;只却;能够ensures that someone cannot guess 从而root password 得到,网络。 Disallow root  login 远程?,(Press y | Y for 是的,,any other key for No),:, Y ,, # #,是否允许远程连mysql 的,根。我用做本地调试,不是远程服务器,所以y了 成功。 By 默认情况下,,MySQL comes  with a database named & # 39;测试# 39;这 anyone 还要访问只却;能够is also intended only for 测试, 以及should be  removed before  moving into a 生产 环境。 Remove test  database 以及access 用吗,(Press y | Y for 是的,,any other key for No),:, Y ,,,,, # #,是否y了删除测试数据库,我选了y ,安康;Dropping  test 数据库… 成功。 ,安康;Removing  privileges 提醒test 数据库… 成功。 Reloading 从而,privilege tables will  ensure that all 变化 made so  far will take  effect 立即。 null null null null null null null如何在Mac下搭建MySQL环境