mac brew install mysql

479 阅读4分钟
# 1. 搜索mysql
brew search mysql

#输出
==> **Formulae**
automysqlbackup                      mysql++                              mysql-client@5.7                     mysql-sandbox                        mysql@5.6                            mysqltuner
mysql                                mysql-client                         mysql-connector-c++                  mysql-search-replace                 mysql@5.7                            qt-mysql

==> **Casks**
mysql-connector-python               mysql-shell                          mysql-utilities                      mysqlworkbench                       navicat-for-mysql                    sqlpro-for-mysql
# 2. 安装5.7版本
brew install mysql@5.7
# 安装输出
Running `brew update --preinstall`...

==> **Auto-updated Homebrew!**

Updated 2 taps (homebrew/core and homebrew/cask).

==> **New Formulae**

adamstark-audiofile            docker-buildx                  gnustep-base                   libeatmydata                   nali                           poac                           tea

astro                          doggo                          go@1.18                        libnetfilter_conntrack         naml                           pocl                           teller

aws-nuke                       dooit                          gokart                         libnftnl                       nb                             podman-compose                 tere

aws2-wrap                      dsda-doom                      gold                           libnl                          neovide                        protobuf@3                     terramate

aztfy                          dtrx                           groestlcoin                    libobjc2                       nftables                       prql-compiler                  tinysearch

berkeley-db@5                  dump1090-mutability            gum                            libpython-tabulate             nmrpflash                      prr                            tlsx

bfgminer                       dumpling                       hatch                          libvatek                       oak                            pymupdf                        toxcore

bore-cli                       dunamai                        helix                          licensor                       ocl-icd                        python-build                   treefmt

c2rust                         dura                           helmify                        livekit                        ohdear-cli                     qbe                            tremor-runtime

cargo-bundle                   editorconfig-checker           hwatch                         livekit-cli                    onlykey-agent                  qsv                            trzsz-go

cargo-crev                     eget                           hyx                            llvm@13                        open62541                      railway                        ttdl

cargo-depgraph                 enex2notion                    ijq                            lucky-commit                   opencl-headers                 redis@6.2                      tuc

cargo-nextest                  erlang@24                      install-peerdeps               lunar-date                     opentelemetry-cpp              req                            tuntox

cargo-udeps                    evernote-backup                interface99                    mabel                          openvi                         rush-parallel                  unisonlang

censys                         fastnetmon                     iptables                       maclaunch                      ouch                           sgn                            uthash

cfonts                         felinks                        jackett                        manifest-tool                  pacmc                          sgr                            vectorscan

chain-bench                    flix                           jaq                            mariadb@10.7                   page                           slither-analyzer               verapdf

circumflex                     flock                          jupp                           markdown-toc                   pax                            smap                           vile

cpp-httplib                    gaze                           kics                           mcap                           pg_cron                        snapcast                       vulkan-loader

cql-proxy                      gcc@11                         ksh93                          meek                           pg_partman                     snowflake                      webkitgtk

create-api                     gcem                           kt-connect                     mesheryctl                     phrase-cli                     solc-select                    x86_64-linux-gnu-binutils

crytic-compile                 git-codereview                 leapp-cli                      metalang99                     pint                           spr                            xdg-ninja

cxgo                           git-delete-merged-branches     levant                         mkp224o                        pipe-rename                    stencil                        xpipe

czg                            git-sync                       lexicon                        mle                            pixie                          svt-av1                        yorkie

dart-sdk                       glib-utils                     lgeneral                       mprocs                         pixiewps                       swtpm                          zx

datatype99                     glider                         libbpf                         mypaint-brushes                pkcs11-tools                   synergy-core

==> **New Casks**

aliwangwang                          chromium-gost                        gittyup                              micromamba                           roam-research                        ui

amazon-luna                          cleaneronepro                        gyroflow                             mighty-mike                          rockboxutility                       ukrainian-typographic-keyboard

app-fair                             cloud189                             hdfview                              moderndeck                           rustdesk                             v2ray-unofficial

archy                                contour                              headlamp                             nanoem                               shop-different                       ved

astrofox                             cro-mag-rally                        httpie                               opencore-patcher                     sol                                  virtualbuddy

audiostellar                         dixa                                 imhex                                orangedrangon-android-messages       sonixd                               weektodo

betterandbetter                      dmg-canvas                           input-source-pro                     orion                                squash                               wirecast

betterdisplay                        drawpile                             iqmol                                oso-cloud                            swiftcord                            workman

bili-downloader                      duckduckgo                           jpc-qlcolorcode                      phpwebstudy                          tailscale                            wow

bilibili-official                    ecamm-live                           juice                                playcover-community                  tdr-kotelnikov                       yousician

bing-wallpaper                       elephicon                            lemonlime                            plex-htpc                            tdr-nova                             yubihsm2-sdk

black-light                          fertigt-slate                        livebook                             polypad                              tdr-vos-slickeq

black-light-pro                      fly-key                              localxpose                           psst                                 tl-legacy

calhash                              gama                                 mbcord                               qspace-pro                           tmpdisk

cardinal                             gama-jdk                             metadatics                           qwerty-fr                            trunk-io

cardpresso                           gamma-control                        miaoyan                              reverso                              twitch-studio

\


You have **7** outdated formulae installed.

You can upgrade them with **brew upgrade**

or list them with **brew outdated**.

\


==> **Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2022-07-19_1**

######################################################################## 100.0%

==> **Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:9e0df163364a5ae07f3ee2cf39083cd74bcb38eeb5250b706e1c02f878d8d632**

==> **Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:9e0df163364a5ae07f3ee2cf39083cd74bcb38eeb5250b706e1c02f878d8d632?se=2022-08-17T07%3A20%3A00Z&sig=77t234OXU4RPgzeuVF8j9OxB2ZG2anWZGefq9iJ**

######################################################################## 100.0%

==> **Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/manifests/1.1.1q**

######################################################################## 100.0%

==> **Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/blobs/sha256:4e7b6cb2252c554a8e25ecae960f2fcd9a7fa742aa3fc99e6b533bb4e5d32483**

==> **Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:4e7b6cb2252c554a8e25ecae960f2fcd9a7fa742aa3fc99e6b533bb4e5d32483?se=2022-08-17T07%3A20%3A00Z&sig=jyUys3k0jOb0CwlrnOl9C6OMuj3c5bijJgaLQFv**

######################################################################## 100.0%

==> **Downloading https://ghcr.io/v2/homebrew/core/mysql/5.7/manifests/5.7.39**

######################################################################## 100.0%

==> **Downloading https://ghcr.io/v2/homebrew/core/mysql/5.7/blobs/sha256:177e5cb2046e5bd02fdae5a388dd435f118f6792cdf33c0f8b845bf1c552175e**

==> **Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:177e5cb2046e5bd02fdae5a388dd435f118f6792cdf33c0f8b845bf1c552175e?se=2022-08-17T07%3A20%3A00Z&sig=Aw6DS8zu3bINDEO5lMy6%2FW4HpPw6zvZEDOFY%**

######################################################################## 100.0%

==> **Installing dependencies for mysql@5.7:** **ca-certificates** **and** **openssl@1.1**

==> **Installing mysql@5.7 dependency:** **ca-certificates**

==> **Pouring ca-certificates--2022-07-19_1.all.bottle.tar.gz**

==> **Regenerating CA certificate bundle from keychain, this may take a while...**

🍺  /opt/homebrew/Cellar/ca-certificates/2022-07-19_1: 3 files, 222.6KB

==> **Installing mysql@5.7 dependency:** **openssl@1.1**

==> **Pouring openssl@1.1--1.1.1q.arm64_monterey.bottle.tar.gz**

🍺  /opt/homebrew/Cellar/openssl@1.1/1.1.1q: 8,097 files, 18MB

==> **Installing** **mysql@5.7**

==> **Pouring mysql@5.7--5.7.39.arm64_monterey.bottle.tar.gz**

==> **/opt/homebrew/Cellar/mysql@5.7/5.7.39/bin/mysqld --initialize-insecure --user=wangruirui9 --basedir=/opt/homebrew/Cellar/mysql@5.7/5.7.39 --datadir=/opt/homebrew/var/mysql --tmpdir=/tmp**

==> **Caveats**

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 restart mysql@5.7 after an upgrade:

  brew services restart 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

==> **Summary**

🍺  /opt/homebrew/Cellar/mysql@5.7/5.7.39: 320 files, 232.3MB

==> **Running `brew cleanup mysql@5.7`...**

Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.

Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

==> **`brew cleanup` has not been run in the last 30 days, running now...**

Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.

Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

Removing: /opt/homebrew/Cellar/ca-certificates/2021-10-26... (3 files, 208.5KB)

Removing: /opt/homebrew/Cellar/ca-certificates/2022-04-26... (3 files, 215.6KB)

Removing: /Users/wangruirui9/Library/Caches/Homebrew/ca-certificates--2022-04-26... (121.8KB)

Removing: /opt/homebrew/Cellar/libunistring/0.9.10... (55 files, 4.6MB)

Removing: /opt/homebrew/Cellar/openssl@1.1/1.1.1l_1... (8,073 files, 18MB)

Removing: /opt/homebrew/Cellar/openssl@1.1/1.1.1o... (8,089 files, 18MB)

Removing: /Users/wangruirui9/Library/Caches/Homebrew/openssl@1.1--1.1.1o... (5MB)

Removing: /Users/wangruirui9/Library/Caches/Homebrew/telnet--63... (53.5KB)

Pruned 0 symbolic links and 2 directories from /opt/homebrew

==> **Caveats**

==> **mysql@5.7**

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 restart mysql@5.7 after an upgrade:

  brew services restart 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
# 3. 启动mysql
brew services start mysql@5.7

# 4. 搜索安装目录 
brew --prefix mysql@5.7
# 输出
/opt/homebrew/opt/mysql@5.7


# 5. 进入安装目录
cd /opt/homebrew/opt/mysql@5.7
# 6. 进入bin
cd bin

# 7. 修改mysql 配置
mysql_secure_installation


```shell
# 输出
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT 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 component?
// 提示是否设置密码
Press y|Y for Yes, any other key for No: y
// 提示选择密码强度等级
There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.
// 按照所选的密码强度要求设定密码
New password:

Re-enter new password:
// 提示密码强度50,不符合要求重新设置密码
Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
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.
// 提示禁止远程root登录
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

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.

// 提示删除默认自带的test数据库
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
// 提示是否重新加载privilege tables
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!
# 也可以在bin 目录下执行以下命令 停止,启动,重启
mysql.server stop
mysql.server start
mysql.server restart