如何在Mac下搭建MySQL环境

技术如何在Mac下搭建MySQL环境小编给大家分享一下如何在Mac下搭建MySQL环境,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧! 方法一:用dmg镜像安装1、安装官网下载

边肖想和大家分享一下如何在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

(0)

相关推荐

  • react中的flux是什么

    技术react中的flux是什么本篇内容主要讲解“react中的flux是什么”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“react中的flux是什么”吧!

    攻略 2021年11月24日
  • 威力登激光雷达连接报套接字绑定失败该怎么办

    技术velodyne lidar连接报socket bind failed该怎么办今天就跟大家聊聊有关velodyne lidar连接报socket bind failed该怎么办,可能很多人都不太了解,为了让大家更加了

    攻略 2021年12月23日
  • R语言中的MongoDB的示例分析

    技术R语言中的MongoDB的示例分析今天就跟大家聊聊有关R语言中的MongoDB的示例分析,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。R利剑MongeDB,分

    攻略 2021年11月23日
  • 游说的读音,一直想收个高级的游说之舌的巨蜥

    技术游说的读音,一直想收个高级的游说之舌的巨蜥我们华山有把如意以下所有的技能都研发出来的帮派,想体验游说来华山,呵呵现在的问道是罩子和如意圈的天下.光把这三种研究完就很困难了游说的读音,谁还愿意花精力,金钱去研究游说之舌

    生活 2021年10月22日
  • Git使用笔记

    技术Git使用笔记 Git使用笔记一、git commit --amend
    本地修改文件,并提交:
    git add .
    git commit -m "message"
    此时:如果发现 message 漏

    礼包 2021年11月30日
  • Android中如何设置TextView渐变颜色和方向及动画效果

    技术Android中如何设置TextView渐变颜色和方向及动画效果这篇文章主要介绍Android中如何设置TextView渐变颜色和方向及动画效果,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!添

    攻略 2021年11月6日