旗下导航:搜·么
当前位置:网站首页 > MySQL教程 > 正文

Mac下MySQL环境搭建的步骤详解【MySQL教程】,macos,mysql,数据库

作者:搜教程发布时间:2019-12-01分类:MySQL教程浏览:48评论:0


导读:本篇文章给人人带来的内容是关于Mac下MySQL环境搭建的步骤详解,有肯定的参考价值,有须要的朋侪能够参考一下,愿望对你有所协助。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(无后台效劳)

本篇文章到这里就已悉数完毕了,更多其他精彩内容能够关注ki4网的MySQL视频教程栏目!

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

标签:macosmysql数据库


欢迎 发表评论: