适合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的目录不一样)

复制代码
[[email protected]:/Users/demo]$vi .bash_profile 
export PATH=/opt/homebrew/bin:$PATH

[[email protected]:/Users/demo]$vi .zshrc
export PATH=/opt/homebrew/bin:$PATH

[[email protected]:/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 [email protected]
...
==> [email protected]
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

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

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"

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

启动

复制代码
  brew services start [email protected]

改密码,检查目录

复制代码
demo@demodeMacBook-Air ~ % /opt/homebrew/opt/[email protected]/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/[email protected]/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
[email protected] started demo ~/Library/LaunchAgents/[email protected]
demo@demodeMacBook-Air mysql % brew services stop [email protected]
Stopping `[email protected]`... (might take a while)
==> Successfully stopped `[email protected]` (label: [email protected])
demo@demodeMacBook-Air mysql % brew services list          
Name      Status User File
[email protected] none  
2.3、卸载和删除
复制代码
demo@demodeMacBook-Air ~ % brew uninstall [email protected]
Uninstalling /opt/homebrew/Cellar/[email protected]/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                   [email protected]             [email protected]              [email protected]              [email protected]
mariadb-connector-c       [email protected]             [email protected]              [email protected]              qt-mariadb
mariadb-connector-odbc    [email protected]              [email protected]              [email protected]

==> 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   [email protected]       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
相关推荐
luoluoal37 分钟前
Java项目之基于ssm的QQ村旅游网站的设计(源码+文档)
java·mysql·mybatis·ssm·源码
luoluoal43 分钟前
Java项目之基于ssm的学校小卖部收银系统(源码+文档)
java·mysql·毕业设计·ssm·源码
veminhe2 小时前
Node.js 数据库 CRUD 项目示例
数据库·node.js
HX科技2 小时前
树莓派_利用Ubuntu搭建gitlab
数据库·ubuntu·gitlab
pursue.dreams2 小时前
Windows 下 MongoDB ZIP 版本安装指南
数据库·windows·mongodb
.R^O^2 小时前
VLAN的知识
linux·服务器·网络·mysql
qiandeqiande2 小时前
数据集成工具推荐,支持数据库、API、消息文件等集成技术,并具备低代码与可视化配置特性
数据库·低代码·系统集成
betazhou3 小时前
基于Windows通过nginx代理访问Oracle数据库
数据库·nginx·oracle·代理
风中飘爻3 小时前
MySQL入门:数据表的创建
数据库·mysql·oracle
今天多喝热水3 小时前
Redis适用场景
数据库·redis