如何在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)

相关推荐

  • 荸荠怎么煮,赤豆煮荸荠的制作方法是怎样的

    技术荸荠怎么煮,赤豆煮荸荠的制作方法是怎样的制作赤豆煮荸荠的原料有:赤豆100克,荸荠100克,料酒10毫升,姜5克,葱10 克,盐3克,鸡精3克,鸡油30毫升荸荠怎么煮。制作方法:(1 )将赤豆去泥沙,洗净;荸荠去皮,

    生活 2021年10月26日
  • C#中可为NULL的运算符怎么用

    技术C#中可为NULL的运算符怎么用这篇文章主要介绍了C#中可为NULL的运算符怎么用,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。?.和?[]null条

    攻略 2021年12月1日
  • javascript中=、==、===是否有区别

    技术javascript中=、==、===是否有区别这篇文章主要为大家展示了“javascript中=、==、===是否有区别”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“j

    攻略 2021年11月14日
  • C#序列号的设计不重复的实现方法是什么

    技术C#序列号的设计不重复的实现方法是什么这篇文章主要介绍“C#序列号的设计不重复的实现方法是什么”,在日常操作中,相信很多人在C#序列号的设计不重复的实现方法是什么问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操

    攻略 2021年11月26日
  • ArrayList扩容机制

    技术ArrayList扩容机制 ArrayList扩容机制写在前面
    数据结构在面试中基本都是常问的,但是一般开发中基本上都是在使用没有去关心过怎么实现的。
    在数据结构中,链表是一种线性存储结构,也就是常

    礼包 2021年11月25日
  • 零钱通的钱怎么转到银行卡,零钱通可以转出到另一张银行卡

    技术零钱通的钱怎么转到银行卡,零钱通可以转出到另一张银行卡零钱通的钱转到银行卡具体步骤如下零钱通的钱怎么转到银行卡:1. 打开微信app,登录,进入我的页面中。2. 在我的页面中选择“支付”,点击“零钱”,在零钱界面进入

    生活 2021年10月25日