暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

适合DBA的brew上手指南

原创 库海无涯 6天前
25

##

适合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
复制
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论