Mac 环境下使用 homebrew 安装和彻底卸载 MySQL5.7

2023-05-16

一、安装 MySQL5.7

在终端执行下列命令:

brew install mysql@5.7

使用 brew 安装好 MySQL 5.7 版本后,此时 MySQL root 用户的密码是空的。我们需要修改一下 MySQL root 用户的密码,步骤如下:

  1. 在终端执行下列命令:
    /usr/local/opt/mysql@5.7/bin/mysql.server start
    
    执行完该条命令后,MySQL 就被启动了起来
  2. 在终端执行下列命令:
    /usr/local/opt/mysql@5.7/bin/mysql_secure_installation
    
    这个命令是执行 mysql 提供的配置向导,启动这个脚本后,即可根据如下命令提示进行初始化设置(比如:重置 root 用户的密码)。
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    
    In order to log into MySQL to secure it, we'll need the current
    password for the root user.  If you've just installed MySQL, and
    you haven't set the root password yet, the password will be blank,
    so you should just press enter here.
    
    Enter current password for root (enter for none): //输入现行root密码,因为初次使用,所以直接回车
    OK, successfully used password, moving on...
    
    Setting the root password ensures that nobody can log into the MySQL
    root user without the proper authorisation.
    
    Set root password? [Y/n] Y //是否设置root密码
    New password:                   // 输入 root 新密码
    Re-enter new password:     // 重新输入 root 新密码
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
    
    By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for 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? [Y/n] 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? [Y/n] 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? [Y/n] 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? [Y/n] Y//重新载入权限表
     ... Success!
    
    All done!  If you've completed all of the above steps, your MySQL
    installation should now be secure.
    
    Thanks for using MySQL!
    

二、MySQL 彻底卸载

在终端依次执行下列命令:

rm -rf /usr/local/etc/my.cnf*

rm -rf /usr/local/Cellar/mysql@5.7/

rm -rf /System/Volumes/Data/usr/local/Cellar/mysql@5.7

rm -rf /System/Volumes/Data/usr/local/etc/my.cnf

rm -rf /System/Volumes/Data/usr/local/Cellar/mysql@5.7

brew uninstall mysql@5.7

rm -rf /usr/local/var/mysql

rm -rf /usr/local/mysql*

rm -rf /Library/LaunchDaemons/com.oracle

brew cleanup

rm -rf /Library/StartupItems/MySQLCOM

rm -rf /Library/PreferencePanes/My*

rm -rf ~/Library/PreferencePanes/My*

rm -rf /Library/Receipts/mysql*

rm -rf /Library/LaunchDaemons/com.oracle

rm -rf /var/db/receipts/com.mysql.*

三、可能遇到的问题

启动 MySQL 提示:The server quit without updating PID file(…) 失败

解决方案:https://blog.csdn.net/zalion/article/details/9274263

四、参考链接

https://www.jianshu.com/p/092691b617ac

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Mac 环境下使用 homebrew 安装和彻底卸载 MySQL5.7 的相关文章

随机推荐

  • Broadcom 802.11n网络适配器,网络连接没有有效的ip配置问题解决

    昨天帮同事解决了一个无线网络的问题 xff1a 可以连接公司的无线热点 xff0c 但无法上网 xff1b 但是连接自己家里的网络后可以正常上网 问题的奇怪之处在于 xff0c 检查了网络设置 xff0c 并没有发现什么配置错误 IP也是自
  • 关于电脑出厂时间查询工具的构思

    在做一个单位的计算机盘点 管理的时候 xff0c 很容易遇见需要知道电脑的采购时间 xff0c 或者出厂时间 这个信息能够帮助管理人员决定电脑是否该按定期报废制度进行报废或更换 目前为止 xff0c 作者接触过的各类电脑 xff0c 没有看
  • Outlook频繁崩溃解决方法

    这几天新换了笔记本 xff0c IT部门帮忙进行了配置 xff0c 拿到手上却屡屡发现邮件系统这出问题那出问题 xff0c 好生烦躁 经过几天的修修补补 xff0c 今天总算完全OK了 xff0c 又恢复到正常的轨道上来了 由于被折磨得够呛
  • Manifest文件详解

    一 关于AndroidManifest xml AndroidManifest xml 是每个android程序中必须的文件 它位于整个项目的根目录 xff0c 描述了package中暴露的组件 xff08 activities servi
  • Android蓝牙完全学习手册

    1 前言 市面上关于Android的技术书籍很多 xff0c 几乎每本书也都会涉及到蓝牙开发 xff0c 但均是上层应用级别的 xff0c 而且篇幅也普遍短小 对于手机行业的开发者 xff0c 要进行蓝牙模块的维护 xff0c 就必须从An
  • 【高级】深入理解Word里的字号、行距、段距、间距、样式

    昨天领导交给我一份文档 xff0c 让我帮忙修改一下 改完后最后一页只有单独的一行 xff0c 打印出来不够美观 因此 xff0c 我缩小了行距 xff0c 把默认的单倍行距改为了固定值28磅 结果是 xff0c 整个文档的确少了一页 xf
  • 笔记本插上耳机后仍在外放Realtek Audio Console不支持此机器

    大年初七 xff0c 开工第一天 下午办公室新来的同事请教的如题问题 他用的华硕笔记本 xff0c 飞行堡垒FX86FE 插上华为耳机 xff0c 耳机始终播放不出来声音 显示已经检测到耳机插入了耳机孔 xff0c 点击弹窗会显示 Real
  • git Filename too long

    全局 git config global core longpaths true 当前仓库 git config core longpaths true 转载于 https www cnblogs com EasonJim p 108038
  • VxWorks入门级开发环境学习

    由于实习需要 xff0c 最近在学习VxWorks xff0c 久闻该操作系统大名 xff0c 一直被其深厚的内力震撼着从未敢去了解 xff0c 直到最近 操作系统Vxworks本身的优点特点等详细信息不多说了 xff0c 这里讲讲几天来我
  • 树莓派 Retropie 4.4中文版使用说明 含roms资源

    漫步云端服务器 http chdong top bbs http www chdong top 相关名词 Retropie Retropie可以将你的树莓派或者PC变成一台复古游戏机 Retropie基于完整的操作系统之上 xff0c 你可
  • selenium 中 css-寻找元素

    等同于 tag名 不改变 elements 61 wd find elements by css selector 39 div 39 elements 61 wd find elements by tag name 39 div 39 i
  • 解决 The following packages have unmet dependencies: 问题

    The following packages have unmet dependencies libvtk5 dev Depends libfreetype6 dev but it is not going to be installed
  • 2.1Ubuntu20.4安装QT5.14.2

    QT简介 xff1a Qt是一个跨平台的C 43 43 图形用户界面库 xff0c 我们平时所说所使用的Qt xff0c 准确的来说是它的GUI编程部分 Qt提供给应用程序开发者建立图形用户界面所需要的功能 xff0c 并且Qt很容易扩展
  • 美国出台最严技术出口管制!14项前沿科技面临封锁

    关注ITValue xff0c 查看企业级市场最新鲜 最具价值的报道 xff01 xff08 本文转载自量子位公众号 xff0c ID xff1a QbitAI xff0c 作者 xff1a 乾明 夏乙 问耕 xff09 美国又打出一套七伤
  • sftp文件上传详解

    JSch是Java Secure Channel的缩写 JSch是一个SSH2的纯Java实现 它允许你连接到一个SSH服务器 xff0c 并且可以使用端口转发 xff0c X11转发 xff0c 文件传输等 xff0c 当然你也可以集成它
  • 数据库设计 ER图

    一 E R图构成要素 E R图也称实体 联系图 Entity Relationship Diagram xff0c 提供了表示实体类型 属性和联系的方法 xff0c 用来描述现实世界的概念模型 它是描述现实世界关系概念模型的有效方法 是表示
  • ssh-keygen -t rsa详解

    ssh keygen q 安静模式 b bits 位数 t dsa ecdsa ed25519 rsa rsa1 加密算法 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 6
  • samba源码编译安装(版本4.13.0)

    目录 前言编译安装samba下载三个包安装依赖共需要安装samba gnutls nettle1 进入解压后的samba目录执行 xff1a 2 进入解压后的gnutls目录执行3 进入解压后的nettle目录执行3 1 卸载已存在nett
  • mybatis+postgresql10插入返回主键ID

    MyBatis如果使用useGeneratedKeys去生成自增列会造成不成功 xff0c 因为官方提供只支持这些数据库 xff1a mybatis generatedkeys xff0c 那么如果要用在oracle和postgresql上
  • Mac 环境下使用 homebrew 安装和彻底卸载 MySQL5.7

    一 安装 MySQL5 7 在终端执行下列命令 xff1a brew install mysql 64 5 7 使用 brew 安装好 MySQL 5 7 版本后 xff0c 此时 MySQL root 用户的密码是空的 我们需要修改一下