边肖想和大家分享一下如何在Mac下搭建MySQL环境。希望你看完这篇文章后有所收获。让我们一起讨论一下。
方法一:用dmg镜像安装
1.安装。
官网下载MySQL Mac安装包,按常规步骤安装。在安装过程中,将出现以下提示:
2019-03-24t 18:27:31.043133 Z1[注]atemporarypasswordsgenerated foroot @ localhost : dfrm 19!O0Xi,其中TdfRm19!O1是初始密码,最好先记住!
2.着陆。
在终端命令行上登录mysql:
$mysql-uroot-p
#输入上述密码。如果此步骤提示未找到: bash : MySQL :命令,请执行以下两个命令来建立软连接:
cd/usr/local/bin
ln-fs/usr/local/MySQL-8 . 0 . 11-MAC OS 10.13-x86 _ 64/bin/MySQL 3。更改密码。
在MySQL8.0.4之前,执行SET PASSWORD=PASSWORD(新密码)。但是新版本不能这样改,因为密码认证改了。具体步骤请参考https://blog.csdn.net/yi247630676/article/details/80352655。
方法二:用 Homebrew 进行安装
众所周知,Mac可以由家酿安装管理,非常方便。如果没有安装自制软件,你可以点击https://brew.sh/安装。
以下是mysql的安装方式。
$brewinstallmysql#安装指定的版本:brewinstallmysql@1.1.1下一步,只需等待。在以下文本出现后,我们已经知道我们需要做什么:
==mysql
我们在没有root password . to securetrun :的情况下安装了MySQL数据库
mysql_secure_installation
MySQL isconfiguredtoonlyallowconnections omlocalhostby default
to connectctrun :
mysql-uroot
to avelaunchdstartmysql nownandrestartatlogin :
brewservicesstartmysql
或者,如果您不想/需要backgroundserviceyounjustrun :
Mysql.serverstart按照描述继续并执行初始化操作:
在初始化$myysql_secure_installation的过程中会出现很多问题。以下是具体问题,用注释说明:
e class="brush:php;toolbar:false">Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: Y ## 回复y 需要密码8位以上,回复n 则不做限制
The password validation component is not available. Proceeding with the further steps without the component.
Please set the password for root here.
New password: ## 设置你的密码
Re-enter new password: ## 再次输入你的密码
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
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 ## 是否移除匿名用户。考虑安全我选了y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures 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) : Y ## 是否允许远程连mysql 的 root。我用做本地调试,不是远程服务器,所以y了
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y ## 是否y了删除test数据库,我选了y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y ## 选y, 重新加载权限列表
Success.
All done!
到此配置就结束了,下面我们启动 mysql 即可,记住以下命令:
$ mysql -u root -p ## 登陆 mysql $ brew services start mysql@5.7 ## 启动 mysql $ brew services stop mysql@5.7 ## 停止 mysql $ mysql.server start ## 启动 mysql(无后台服务)
看完了这篇文章,相信你对“如何在Mac下搭建MySQL环境”有了一定的了解,如果想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!
内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/54422.html