适合DBA的brew上手指南

适合DBA的brew上手指南

1、brew安装

1.1、安装方法概述

https://brew.sh/

安装方法1:

复制代码
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

安装方法2:

.pkg 安装器下载地址:https://github.com/Homebrew/brew

1.2、安装

#这里选择的是pkg的安装器,下一步>下一步就可以了

复制代码
This package will install to:
	⁃	/opt/homebrew on Apple Silicon
	⁃	/usr/local/bin/brew and /usr/local/Homebrew on Intel

设置环境变量(Apple silicon和Intel的目录不一样)

复制代码
[root@demodeMacBook-Air.local:/Users/demo]$vi .bash_profile 
export PATH=/opt/homebrew/bin:$PATH

[root@demodeMacBook-Air.local:/Users/demo]$vi .zshrc
export PATH=/opt/homebrew/bin:$PATH

[root@demodeMacBook-Air.local:/Users/demo]$exit
logout
demo@demodeMacBook-Air ~ % source ~/.bash_profile 
demo@demodeMacBook-Air ~ % source ~/.zshrc  

demo@demodeMacBook-Air ~ % brew --version
Homebrew 4.4.25
1.3、测试
复制代码
demo@demodeMacBook-Air ~ % brew install wget

demo@demodeMacBook-Air ~ % wget --version
GNU Wget 1.25.0 在 darwin22.6.0 上编译。

#下载太慢只能开代理或者更换源

2、数据库基础测试

#这里使用mysql

2.1、安装
复制代码
demo@demodeMacBook-Air ~ % brew install mysql@8.4
...
==> mysql@8.4
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 -u root

mysql@8.4 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@8.4 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/mysql@8.4/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql@8.4 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/mysql@8.4/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/mysql@8.4/include"

To start mysql@8.4 now and restart at login:
  brew services start mysql@8.4
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/mysql@8.4/bin/mysqld_safe --datadir\=/opt/homebrew/var/mysql

启动

复制代码
  brew services start mysql@8.4

改密码,检查目录

复制代码
demo@demodeMacBook-Air ~ % /opt/homebrew/opt/mysql@8.4/bin/mysql -uroot -p
Enter password: 

mysql> alter user root@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye
demo@demodeMacBook-Air ~ % /opt/homebrew/opt/mysql@8.4/bin/mysql -uroot -p123456

mysql> show variables like 'datadir';
+---------------+--------------------------+
| Variable_name | Value                    |
+---------------+--------------------------+
| datadir       | /opt/homebrew/var/mysql/ |
+---------------+--------------------------+
1 row in set (0.01 sec)

mysql> show variables like 'log_error';
+-------------------------------+----------------------------------------+
| Variable_name                 | Value                                  |
+-------------------------------+----------------------------------------+
| log_error                     | ./demodeMacBook-Air.local.err          |
+-------------------------------+----------------------------------------+
11 rows in set (0.00 sec)

mysql> \q
Bye
2.2、服务检查和停止
复制代码
demo@demodeMacBook-Air mysql % brew services list  
Name      Status  User File
mysql@8.4 started demo ~/Library/LaunchAgents/homebrew.mxcl.mysql@8.4.plist
demo@demodeMacBook-Air mysql % brew services stop mysql@8.4
Stopping `mysql@8.4`... (might take a while)
==> Successfully stopped `mysql@8.4` (label: homebrew.mxcl.mysql@8.4)
demo@demodeMacBook-Air mysql % brew services list          
Name      Status User File
mysql@8.4 none  
2.3、卸载和删除
复制代码
demo@demodeMacBook-Air ~ % brew uninstall mysql@8.4
Uninstalling /opt/homebrew/Cellar/mysql@8.4/8.4.4_3... (322 files, 303.6MB)
==> Autoremoving 7 unneeded formulae:
abseil
icu4c@77
lz4
protobuf@29
xz
zlib
zstd
Uninstalling /opt/homebrew/Cellar/protobuf@29/29.4... (445 files, 15.4MB)
Uninstalling /opt/homebrew/Cellar/zlib/1.3.1... (14 files, 403.5KB)
Uninstalling /opt/homebrew/Cellar/zstd/1.5.7... (32 files, 2.2MB)
Uninstalling /opt/homebrew/Cellar/icu4c@77/77.1... (277 files, 81.2MB)
Uninstalling /opt/homebrew/Cellar/lz4/1.10.0... (24 files, 714.2KB)
Uninstalling /opt/homebrew/Cellar/xz/5.6.4... (96 files, 2.4MB)
Uninstalling /opt/homebrew/Cellar/abseil/20240722.1... (772 files, 11.8MB)
demo@demodeMacBook-Air ~ % cd /opt/homebrew/ 
demo@demodeMacBook-Air homebrew % ls
CHANGELOG.md	Cellar		LICENSE.txt	bin		etc		manpages	sbin
CONTRIBUTING.md	Dockerfile	Library		completions	include		opt		share
Caskroom	Frameworks	README.md	docs		lib		package		var
demo@demodeMacBook-Air homebrew % cd var 
demo@demodeMacBook-Air var % ls
homebrew	mysql
demo@demodeMacBook-Air var % cd mysql
demo@demodeMacBook-Air mysql % ls
#ib_16384_0.dblwr		ca-key.pem			mysql				server-key.pem
#ib_16384_1.dblwr		ca.pem				mysql.ibd			sys
#innodb_redo			client-cert.pem			mysql_upgrade_history		undo_001
#innodb_temp			client-key.pem			performance_schema		undo_002
auto.cnf			demodeMacBook-Air.local.err	private_key.pem
binlog.000001			ib_buffer_pool			public_key.pem
binlog.index			ibdata1				server-cert.pem
demo@demodeMacBook-Air mysql % cd ..
demo@demodeMacBook-Air var % ls -lsa
total 0
0 drwxrwxr-x   4 demo  admin   128  3 24 14:58 .
0 drwxr-xr-x  33 demo  admin  1056  3 24 11:41 ..
0 drwxrwxr-x   4 demo  admin   128  3 24 14:44 homebrew
0 drwxr-xr-x  27 demo  admin   864  3 24 15:06 mysql
demo@demodeMacBook-Air var % rm -fr mysql

3、其他数据库服务

复制代码
demo@demodeMacBook-Air var % brew search mariadb
==> Formulae
mariadb                   mariadb@10.10             mariadb@10.5              mariadb@11.0              mariadb@11.4
mariadb-connector-c       mariadb@10.11             mariadb@10.6              mariadb@11.1              qt-mariadb
mariadb-connector-odbc    mariadb@10.4              mariadb@10.9              mariadb@11.2

==> Casks
maria                                                             navicat-for-mariadb
demo@demodeMacBook-Air var % brew search postgresql
==> Formulae
postgresql-hll            postgresql@12             postgresql@14             postgresql@16             qt-postgresql
postgresql@11             postgresql@13             postgresql@15             postgresql@17             postgrest

==> Casks
navicat-for-postgresql                                            posture-pal

If you meant "postgresql" specifically:
postgresql breaks existing databases on upgrade without human intervention.

See a more specific version to install with:
  brew formulae | grep postgresql@
demo@demodeMacBook-Air var % brew search mongodb   
==> Formulae
mongodb-atlas-cli                           mongosh                                     monetdb

==> Casks
gcollazo-mongodb                            mongodb-compass-readonly                    mongodbpreferencepane
mongodb-compass                             mongodb-compass@beta                        mongotron
mongodb-compass-isolated-edition            mongodb-realm-studio                        nosqlbooster-for-mongodb
demo@demodeMacBook-Air var % brew search redis  
==> Formulae
hiredis         iredis          redis           redis-leveldb   redis@6.2       redir           redict          redo

==> Casks
another-redis-desktop-manager               medis                                       redis-pro
jpadilla-redis                              redis-insight
demo@demodeMacBook-Air var % brew search oracle
==> Formulae
potrace

==> Casks
color-oracle                     oracle-jdk                       oracle-jdk-javadoc@21            oracle-jdk@21
navicat-for-oracle               oracle-jdk-javadoc               oracle-jdk@17                    orange
demo@demodeMacBook-Air var % 

4、常用命令

复制代码
demo@demodeMacBook-Air var % brew --help
Example usage:
  brew search TEXT|/REGEX/
  brew info [FORMULA|CASK...]
  brew install FORMULA|CASK...
  brew update
  brew upgrade [FORMULA|CASK...]
  brew uninstall FORMULA|CASK...
  brew list [FORMULA|CASK...]

Troubleshooting:
  brew config
  brew doctor
  brew install --verbose --debug FORMULA|CASK

Contributing:
  brew create URL [--no-fetch]
  brew edit [FORMULA|CASK...]

Further help:
  brew commands
  brew help [COMMAND]
  man brew
  https://docs.brew.sh
相关推荐
白鲸开源1 小时前
(二)从分层架构到数据湖仓架构:数据仓库分层下的技术架构与举例
大数据·数据库·数据分析
阿维的博客日记1 小时前
从夯到拉的Redis和MySQL双写一致性解决方案排名
redis·分布式·mysql
好玩的Matlab(NCEPU)1 小时前
Redis vs RabbitMQ 对比总结
数据库·redis·rabbitmq
21号 11 小时前
16.MySQL 服务器配置与管理
服务器·数据库·mysql
我的offer在哪里1 小时前
MongoDB
数据库·mongodb
SamDeepThinking2 小时前
为超过10亿条记录的订单表新增字段
mysql
练习时长一年3 小时前
AI开发结构化输出
数据库
IvorySQL3 小时前
灾难恢复工具内核细节探究与分享
数据库·postgresql·开源
lypzcgf3 小时前
商城小程序数据库表结构文档
数据库·小程序·电商
jjw_zyfx3 小时前
Ubuntu上vue3 vite使用MBTiles搭建地图服务器
服务器·数据库·ubuntu