Mac下使用Homebrew安装MySQL5.7

Mac下使用Homebrew安装MySQL5.7

  • 1. 安装Homebrew & Oh-My-Zsh
  • 2. 查询软件信息
  • 3. 执行安装命令
  • 4. 开机启动
  • 5. 服务状态查询
  • 6. 初始化配置
  • 7. 登录测试
    • 7.1 终端登录
    • 7.2 客户端登录
  • 参考

在这里插入图片描述

1. 安装Homebrew & Oh-My-Zsh

mac下如何安装homebrew
MacOS安装Homebrew与Oh-My-Zsh

2. 查询软件信息

% brew search mysql==> Formulae
automysqlbackup       mysql                 mysql++               mysql-client          mysql-client@5.7      mysql-connector-c++   mysql-sandbox         mysql-search-replace  mysql@5.6             mysql@5.7             mysqltuner            qt-mysql==> Casks
mysql-connector-python                                mysql-shell                                           mysqlworkbench                                        navicat-for-mysql                                     sqlpro-for-mysql

3. 执行安装命令

% brew install mysql@5.7
==> Fetching dependencies for mysql@5.7: ca-certificates, openssl@3, libevent, lz4, openssl@1.1, abseil, jsoncpp and protobuf==> Installing dependencies for mysql@5.7: ca-certificates, openssl@3, libevent, lz4, openssl@1.1, abseil, jsoncpp and protobufWe've installed your MySQL database without a root password. To secure it run:mysql_secure_installationMySQL is configured to only allow connections from localhost by defaultTo connect run:mysql -urootmysql@5.7 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.If you need to have mysql@5.7 first in your PATH, run:echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrcFor compilers to find mysql@5.7 you may need to set:export LDFLAGS="-L/opt/homebrew/opt/mysql@5.7/lib"export CPPFLAGS="-I/opt/homebrew/opt/mysql@5.7/include"To start mysql@5.7 now and restart at login:brew services start mysql@5.7
Or, if you don't want/need a background service you can just run:/opt/homebrew/opt/mysql@5.7/bin/mysqld_safe --datadir\=/opt/homebrew/var/mysql

4. 开机启动

% brew services start mysql@5.7
==> Successfully started `mysql@5.7` (label: homebrew.mxcl.mysql@5.7)

5. 服务状态查询

% brew services list           Name      Status  User          File
mysql@5.7 started tanghonggang1 ~/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist

6. 初始化配置

~ mysql_secure_installationSecuring the MySQL server deployment.Connecting to MySQL using a blank password.VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?Press y|Y for Yes, any other key for No: N
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
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) : N... skipping.
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) : N... skipping.
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
Success.All done! 

如果执行报错 zsh: command not found: mysql_secure_installation。执行

echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

7. 登录测试

7.1 终端登录

~ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.43 HomebrewCopyright (c) 2000, 2023, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> 

7.2 客户端登录

在这里插入图片描述

参考

MySQL 5.7的Homebrew安装 - MacOS
macOS brew安装mysql和安装问题解决 关于zsh: command not found: mysql问题解决

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/98332.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【51单片机实验笔记】声学篇(一) 蜂鸣器基本控制

目录 前言硬件介绍PWM基础蜂鸣器简介 原理图分析蜂鸣器驱动电路 软件实现蜂鸣器短鸣蜂鸣器功能封装 总结 前言 蜂鸣器在生活中的应用实则相当广泛。通过本章你将学会制造噪声 (笑~)你将学会驱动它们,并发出响声。 硬件介绍 PWM基础 占空比…

低压配电室电力安全解决方案

低压电气安全监控运维系统是力安科技基于物联网核心技术自主开发的高可靠性安全监测系统。其工作原理是利用物联网、云计算、大数据、数字传感技术及RFID无线射频识别技术来获取低压配电回路电压、电流、温度、有功、无功、功率因数等全电量的采集及配电线路的漏电、温度的实时…

AIGC+思维导图:提升你的学习与工作效率的「神器」

目录 一、产品简介 二、功能介绍 2.1 AI一句话生成思维导图 2.2百万模版免费用 2.3分屏视图,一屏读写 2.4团队空间,多人协作 2.5 云端跨平台化 2.6 免费够用,会员功能更强大 2.7 支持多种格式的导入导出 三、使用教程 3.1 使用AI…

Tomcat 日志乱码问题解决

我就是三井,一个永不放弃希望的男人。——《灌篮高手》 Tomcat 日志乱码问题解决 乱码原因:字符编码不一致 如:国内电脑一般都是GBK编码,而Tomcat日志使用的是UTF-8编码 解决方法:将对应字符编码由 UTF-8 改为 GBK 即…

HTML5-3-表格

文章目录 属性边框属性标题跨行和跨列单元格边距 HTML 表格由 <table> 标签来定义。 tr&#xff1a;tr 是 table row 的缩写&#xff0c;表示表格的一行。td&#xff1a;td 是 table data 的缩写&#xff0c;表示表格的数据单元格。th&#xff1a;th 是 table header的缩…

C++ 模板

模板&#xff1a; 模板&#xff0c;即数据是灵魂&#xff0c;其余为肉身&#xff0c;正所谓有趣的灵魂万里挑一&#xff0c;所以想要模板变得完美&#xff0c;关键在于数据&#xff1b;其余不过是抄作业的框架。 模板函数&#xff1a; 模板函数可以自动推导出你传给他的数据类型…

学习Bootstrap 5的第四天

目录 表格 基础表格 实例 条纹表格 实例 带边框表格 实例 有悬停效果的行 实例 黑色/深色表格 实例 黑色/深色条纹表格 实例 可悬停的黑色/深色表格 实例 无边框表格 实例 上下文类 可用的上下文类&#xff1a; 实例 表头颜色 实例 小型表格 实例 响应…

大模型 Dalle2 学习三部曲(二)clip学习

clip论文比较长48页&#xff0c;但是clip模型本身又比较简单&#xff0c;效果又奇好&#xff0c;正所谓大道至简&#xff0c;我们来学习一下clip论文中的一些技巧&#xff0c;可以让我们快速加深对clip模型的理解&#xff0c;以及大模型对推荐带来革命性的变化。 clip结构 首选…

CocosCreator3.8研究笔记(五)CocosCreator 脚本说明及使用(下)

在Cocos Creator中&#xff0c;脚本代码文件分为模块和插件两种方式&#xff1a; 模块一般就是项目的脚本&#xff0c;包含项目中创建的代码、引擎模块、第三方模块。 插件脚本&#xff0c;是指从 Cocos Creator 属性检查器中导入的插件&#xff0c;一般是引入第三方引入库文件…

【从0学习Solidity】2. 值类型详解

Solidity极简入门: 2. 值类型 博主简介&#xff1a;不写代码没饭吃&#xff0c;一名全栈领域的创作者&#xff0c;专注于研究互联网产品的解决方案和技术。熟悉云原生、微服务架构&#xff0c;分享一些项目实战经验以及前沿技术的见解。关注我们的主页&#xff0c;探索全栈开发…

微服务设计和高并发实践

文章目录 1、微服务的设计原则1.1、服务拆分方法1.2、微服务的设计原则1.3、微服务架构 2、高并发系统的一些优化经验2.1、提高性能2.1.1、数据库优化2.1.2、使用缓存2.1.3、服务调用优化2.1.4、动静分离2.1.5、数据库读写分离 2.2、服务高可用2.2.1、限流和服务降级2.2.2、隔离…

亲测有效:虚拟机安装gcc,报错Could not retrieve mirrorlist http://mirrorlist.centos.org

&#xff08;网卡配置资料&#xff09; 原因&#xff1a; 网络问题 报错详情&#xff1a; One of the configured repositories failed (未知),and yum doesnt have enough cached data to continue. At this point the onlysafe thing yum can do is fail. There are a few …