Mac M1 安装mysql

安装

不是所有版本都能安装成功的

% brew install mysql@5.6
Warning: mysql@5.6 has been deprecated because it is not supported upstream!
Error: mysql@5.6: no bottle available!
You can try to install from source with:
  brew install --build-from-source mysql@5.6
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.
% brew install mysql@5.7
Warning: mysql@5.7 5.7.34 is already installed and up-to-date.
To reinstall 5.7.34, run:
  brew reinstall mysql@5.7

mysql5.7的版本就可以安装成功。

配置环境变量

# 终端
echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
 
# 刷新 ~/.zshrc
source ~/.zshrc

查看版本

% mysql --version
mysql  Ver 14.14 Distrib 5.7.34, for osx10.16 (x86_64) using  EditLine wrapper

mysql 常用命令

mysql.server start  # 启动mysql

mysql.server stop # 停止mysql

mysql.server restart # 重启mysql

设置初始密码

% mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.34 Homebrew

Copyright (c) 2000, 2021, 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> 
set password for 'root'@'localhost'=password('123456');

查看mysql进程

% ps -ef | grep mysql
  501  4692     1   0  1:47下午 ttys000    0:00.02 /bin/sh /opt/homebrew/Cellar/mysql@5.7/5.7.34/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql --pid-file=/opt/homebrew/var/mysql/jiqingdeMBP.pid
  501  4792  4692   0  1:47下午 ttys000    0:00.25 /opt/homebrew/Cellar/mysql@5.7/5.7.34/bin/mysqld --basedir=/opt/homebrew/Cellar/mysql@5.7/5.7.34 --datadir=/opt/homebrew/var/mysql --plugin-dir=/opt/homebrew/Cellar/mysql@5.7/5.7.34/lib/plugin --log-error=jiqingdeMBP.err --pid-file=/opt/homebrew/var/mysql/jiqingdeMBP.pid
  501  4815   682   0  1:52下午 ttys000    0:00.00 grep mysql
  501  4813  4802   0  1:52下午 ttys001    0:00.02 mysql -uroot -p
posted @   TBHacker  阅读(6023)  评论(2编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
历史上的今天:
2020-06-04 小程序使用字体
2020-06-04 字蛛,抽取字体。让引用文件更小。
2019-06-04 配置https域名
2019-06-04 PHP-FPM配置与调优
2018-06-04 PHP自动加载
2018-06-04 ubuntu安装shadowsocks
2018-06-04 pip升级
点击右上角即可分享
微信分享提示