百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>数据库> Mac下MySQL环境搭建的步骤详解
分享文章到:

Mac下MySQL环境搭建的步骤详解

发布时间:08/01 来源:未知 浏览: 关键词:
?本篇文章给大家带来的内容是对于Mac下MySQL环境搭建的步骤详解,有一定的参照 价值,有需要的伴侣可以参照 一下,但愿对你有所帮忙。 本篇文章给大家带来的内容是对于Mac下MySQL环境搭建的步骤详解,有一定的参照 价值,有需要的伴侣可以参照 一下,但愿对你有所帮忙。

Mac 下安装 MySQL 还是很利便的, 总结来看有2个办法。

办法一:用dmg镜像安装

1、安装

官网下载好 MySQL Mac 版安装包,通例步骤安装,安装历程中会涌现如下提醒:

2019-03-24T18:27:31.043133Z 1 [Note] A temporary password is generated for root@localhost: TdfRm19!o0Xi

其中TdfRm19!o0Xi是初始密码,最佳先记住!

2、登陆

在终端下令行 登陆mysql:

$ mysql -u root -p
# 输入上述密码即可

要是这一步提醒: bash: mysql: command not found, 施行下面2个下令做个软连贯即可:

cd /usr/local/bin
ln -fs /usr/local/mysql-8.0.11-macos10.13-x86_64/bin/mysql mysql

3、修改密码

在 MySQL8.0.4 之前,施行 SET PASSWORD=PASSWORD('新密码') 即可。但新版本不克不及这样改了,由于密码认证变了。概括步骤可以参照 https://blog.csdn.net/yi247630676/article/details/80352655。

办法二:用 Homebrew 进行安装

总所周知,Mac 可以应用 homebrew 进行安装治理,十分利便,要是没有安装 homebrew, 可以点击 https://brew.sh/ 安装。

下面是 mysql 的安装方式

$ brew install mysql   # 安装指定版本: brew install mysql@1.1.1

接下来只有期待就可以了,涌现下面文字后我们已经很分明我们需要做什么了:

==> mysql
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -u root

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start

按注明继续施行,进行初始化操纵:

$ myysql_secure_installation

初始化历程中会有许多题目,下列是概括题目局部,以注释为解释:

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(无后台办事)

本篇文章到这里就已经全部完毕了,更多其他出色内容可以关注百分百源码网的MySQL视频教程栏目!

以上就是Mac下MySQL环境搭建的步骤详解的细致内容,更多请关注 百分百源码网 其它相干文章!

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有151人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板