Mac下使用Homebrew安装MySQL5.7

这篇具有很好参考价值的文章主要介绍了Mac下使用Homebrew安装MySQL5.7。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Mac下使用Homebrew安装MySQL5.7,macos,mysql

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 protobuf

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 -uroot

mysql@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"' >> ~/.zshrc

For 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_installation

Securing 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 Homebrew

Copyright (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 客户端登录

Mac下使用Homebrew安装MySQL5.7,macos,mysql

参考

MySQL 5.7的Homebrew安装 - MacOS
macOS brew安装mysql和安装问题解决 关于zsh: command not found: mysql问题解决文章来源地址https://www.toymoban.com/news/detail-681393.html

到了这里,关于Mac下使用Homebrew安装MySQL5.7的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Mac M1通过homebrew安装Redis报错(perl: unknown or unsupported macOS version: :dunno)

    升级homebrew,命令如下: 通过命令 brew install redis 安装Redis,异常如下: 参考博文MAC 升级后brew报错后,运行命令 brew update-reset ,结果如下: 查看homebrew版本( brew --version ),结果为: 最终解决 上述 brew update-reset 升级命令即为该问题的解决办法。homebrew升级完成后,重新运行

    2024年02月07日
    浏览(49)
  • MySql启动错误(Mac系统 安装 mysql-8.0.32-macos13-arm64 后每次点击启动 无法启动) --- 已解决

    MySql启动的时候: 立即变红! 查看日志如下: 2023-03-04T14:18:01.089671Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.32) MySQL Community Server - GPL. 2023-03-04T14:18:10.304169Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.32) starting as process 90802 2023-03-04T14:18:10.3

    2023年04月19日
    浏览(36)
  • 如何在MacOS使用homebrew安装Nginx

    参考文章地址 在确保MacOS 安装Homebrew成功以后,执行如下命令 注意 :Nginx安装成功后会提示目录位置;每个人的系统可能因为Homebrew的安装位置不同而不同,所以这几个目录位置要记下来,方便后期配置和维护Nginx 根据上图可知我本机的几个重要的文件位置: nginx.conf 配置文

    2024年02月06日
    浏览(34)
  • 安装指定版本的mysql(安装mysql5

    安装软件的三种方式: rpm 安装 源代码编译安装 yum仓库安装 本地光盘 阿里云yum源 自建yum仓库文件夹 去mysql官网 寻找该软件下的地址,设置为yum仓库即可(可指定版本) 先检查是否自带了mysql 有的话 mariadb同理 有的话 https://repo.mysql.com/yum/ 找到对应版本 例如5.7 https://repo.m

    2024年02月08日
    浏览(62)
  • mysql基础 - mysql5.7版本安装

    本文章是学习mysql5.7版本的安装教程

    2024年02月09日
    浏览(39)
  • 安装指定版本的mysql(mysql5.7)

    安装软件的三种方式: rpm 安装 源代码编译安装 yum仓库安装 本地光盘 阿里云yum源 自建yum仓库文件夹 去mysql官网 寻找该软件下的地址,设置为yum仓库即可(可指定版本) 先检查是否自带了mysql 有的话 mariadb同理 有的话 https://repo.mysql.com/yum/ 找到对应版本 例如5.7 https://repo.m

    2024年02月08日
    浏览(37)
  • MySQL5.7安装

    1.1 下载安装 下载安装包https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-winx64.zip安装到想要安装的目录(路径不要有中文) 1.2 添加环境变量 我的电脑-属性-高级-环境变量,加入%D:softwareMySQLmysql-5.7bin;(注意修改为自己的路径) 1.3 修改配置文件 在mysql-5.7目录下创建my.ini文件 添加

    2024年02月03日
    浏览(25)
  • 使用Homebrew在Mac上安装Git

    仅针对第一次安装使用Git 1.配置用户名,用户名,不推荐使用中文,最好使用拼音或者英文作为用户名 2.配置邮箱  如果公司并没有加密,可以使用http拉取代码,这一步可省略 出现上面这类数据,说明公钥生成成功 查看公钥  然后录登录gitlab,进入设置里,在ssh keys里添加秘钥即可

    2024年02月11日
    浏览(36)
  • 【MySQL】CentOS编译安装MySQL5.7实战

    这篇文章是关于MySQL编译安装的,重点掌握的是编译的过程,以及体会排错的痛苦。出错在所难免,最重要的是要有一颗不放弃的心。 本文收录于《数据库入门与精通》专栏, 本专栏写作的过程中,联合了csdn几位DBA大佬,目前正在整理更新目录,力争让大家学到一些真东西,

    2024年02月16日
    浏览(48)
  • MySQL5.5安装图解

    一、 MYSQL 的安装 1、打开下载的mysql安装文件mysql-5.5.27-win32.zip,双击解压缩,运行“setup.exe” 2、选择安装类型,有“Typical(默认)”、“Complete(完全)”、“Custom(用户自定义)”三个选项,选择“Custom”,按“next”键继续 3、点选“Browse”,手动指定安装目录 4、填上安装

    2023年04月16日
    浏览(26)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包