Mac系统上安装Mysql环境

Mac系统下mysql卸载

假如自己电脑中已经安装mysql想完全卸载mysql时请看:
在这里插入图片描述
mysql完全删除

以下是mysql的默认安装的安装路径

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*

还需要细致检查一下一下路径中是否存在mysql的相关内容

检查/usr/local/Cellar目录是否有mysql文件,有的话删除。
检查/usr/local/var 里的mysql文件,有的话删除。
检查/tmp 里的mysql.sock、mysql.sock.lock、 my.cnf文件,有的话删除。
err文件以及pid文件都是在/usr/local/var/mysql中,有的话删除。
brew安装的安装包存储在/usr/local/Library/Cache/Homebrew,有的话删除。
执行brew cleanup。

删除mysql相关信息
在这里插入图片描述
更新brew
在这里插入图片描述
准备安装mysql
执行下载命令

brew install mysql@8.0

安装结果

chenfubao@chenfubaodeMacBook-Pro opt % brew install mysql@8.0   
mysql 8.0.27_1 is already installed but outdated (so it will be upgraded).
==> Fetching dependencies for mysql: icu4c, ca-certificates, openssl@1.1, libcbor, libfido2, lz4, protobuf, zlib, xz and zstd
==> Fetching icu4c
==> Downloading https://ghcr.io/v2/homebrew/core/icu4c/manifests/72.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/icu4c/blobs/sha256:899d9a8e7ab10896afad66a3d3c9053a5a10ae290b23197b1210
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:899d9a8e7ab10896afad66a3d3c9053a5a1
######################################################################## 100.0%
==> Fetching ca-certificates
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2023-01-10
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:11fe9d0a98a2ac454fa1db95762a697c3340f46560
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:11fe9d0a98a2ac454fa1db95762a697c334
######################################################################## 100.0%
==> Fetching openssl@1.1
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/manifests/1.1.1t
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/blobs/sha256:c357ccf7ece01905099a0cde58a2bbfb14141edb3aafed
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:c357ccf7ece01905099a0cde58a2bbfb141
######################################################################## 100.0%
==> Fetching libcbor
==> Downloading https://ghcr.io/v2/homebrew/core/libcbor/manifests/0.10.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libcbor/blobs/sha256:b748fb213e434fe650e0964d72f84275a5aac3620b336778db
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:b748fb213e434fe650e0964d72f84275a5a
######################################################################## 100.0%
==> Fetching libfido2
==> Downloading https://ghcr.io/v2/homebrew/core/libfido2/manifests/1.13.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libfido2/blobs/sha256:6bd137a882ad45647044ba1cc6f4c9ac582a2d0383e7ed7d0
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:6bd137a882ad45647044ba1cc6f4c9ac582
######################################################################## 100.0%
==> Fetching lz4
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/manifests/1.9.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/blobs/sha256:aafb93487e108d302d060265898e4eaa82f5c806ff36dec50871db
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:aafb93487e108d302d060265898e4eaa82f
######################################################################## 100.0%
==> Fetching protobuf
==> Downloading https://ghcr.io/v2/homebrew/core/protobuf/manifests/21.12-1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/protobuf/blobs/sha256:d64e264d07b331a8043c35d608de0871e9df4f9a9b208d5d8
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:d64e264d07b331a8043c35d608de0871e9d
######################################################################## 100.0%
==> Fetching zlib
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/manifests/1.2.13
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/blobs/sha256:495733577a835472554be619e26ad09fa62684d1d1eba3efae5a8
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:495733577a835472554be619e26ad09fa62
######################################################################## 100.0%
==> Fetching xz
==> Downloading https://ghcr.io/v2/homebrew/core/xz/manifests/5.4.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/xz/blobs/sha256:55e32fb63afac31a9d21bef5e8e310f2ca0629f055d1a72cb5f14d7
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:55e32fb63afac31a9d21bef5e8e310f2ca0
######################################################################## 100.0%
==> Fetching zstd
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/manifests/1.5.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/blobs/sha256:0e425c420f3a24a3b5e1cd932e01855b1945465467c0cf0a5f25e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:0e425c420f3a24a3b5e1cd932e01855b194
######################################################################## 100.0%
==> Fetching mysql
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/manifests/8.0.32
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/blobs/sha256:8678cc4dc2a4881e0b3fbba64ffece73f153254966ed7ae8816e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:8678cc4dc2a4881e0b3fbba64ffece73f15
######################################################################## 100.0%
==> Upgrading mysql@8.0
  -> 8.0.32 

==> Installing dependencies for mysql: icu4c, ca-certificates, openssl@1.1, libcbor, libfido2, lz4, protobuf, zlib, xz and zstd
==> Installing mysql dependency: icu4c
==> Pouring icu4c--72.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/icu4c/72.1: 263 files, 78MB
==> Installing mysql dependency: ca-certificates
==> Pouring ca-certificates--2023-01-10.all.bottle.tar.gz
==> Downloading https://formulae.brew.sh/api/cask.json
######################################################################## 100.0%
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺  /usr/local/Cellar/ca-certificates/2023-01-10: 3 files, 216.9KB
==> Installing mysql dependency: openssl@1.1
==> Pouring openssl@1.1--1.1.1t.big_sur.bottle.tar.gz
==> Downloading https://formulae.brew.sh/api/formula.json
######################################################################## 100.0%
🍺  /usr/local/Cellar/openssl@1.1/1.1.1t: 8,101 files, 18.5MB
==> Installing mysql dependency: libcbor
==> Pouring libcbor--0.10.2.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/libcbor/0.10.2: 31 files, 175.4KB
==> Installing mysql dependency: libfido2
==> Pouring libfido2--1.13.0.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/libfido2/1.13.0: 547 files, 1.2MB
==> Installing mysql dependency: lz4
==> Pouring lz4--1.9.4.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/lz4/1.9.4: 22 files, 718.8KB
==> Installing mysql dependency: protobuf
==> Pouring protobuf--21.12.big_sur.bottle.1.tar.gz
🍺  /usr/local/Cellar/protobuf/21.12: 285 files, 10.2MB
==> Installing mysql dependency: zlib
==> Pouring zlib--1.2.13.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/zlib/1.2.13: 13 files, 425KB
==> Installing mysql dependency: xz
==> Pouring xz--5.4.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/xz/5.4.1: 95 files, 1.6MB
==> Installing mysql dependency: zstd
==> Pouring zstd--1.5.4.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/zstd/1.5.4: 31 files, 2.5MB
==> Installing mysql
==> Pouring mysql--8.0.32.big_sur.bottle.tar.gz
==> /usr/local/Cellar/mysql/8.0.32/bin/mysqld --initialize-insecure --user=chenfubao --basedir=/usr/local/Cellar/mysql/8
Last 15 lines from /Users/chenfubao/Library/Logs/Homebrew/mysql/post_install.01.mysqld:
2023-02-23 15:38:28 +0800

/usr/local/Cellar/mysql/8.0.32/bin/mysqld
--initialize-insecure
--user=chenfubao
--basedir=/usr/local/Cellar/mysql/8.0.32
--datadir=/usr/local/var/mysql
--tmpdir=/tmp

2023-02-23T07:38:33.899197Z 0 [System] [MY-013169] [Server] /usr/local/Cellar/mysql/8.0.32/bin/mysqld (mysqld 8.0.32) initializing of server in progress as process 17528
2023-02-23T07:38:33.900625Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2023-02-23T07:38:33.901388Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2023-02-23T07:38:33.901397Z 0 [ERROR] [MY-013236] [Server] The designated data directory /usr/local/var/mysql/ is unusable. You can remove all files that the server added to it.
2023-02-23T07:38:33.901485Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-02-23T07:38:33.901688Z 0 [System] [MY-010910] [Server] /usr/local/Cellar/mysql/8.0.32/bin/mysqld: Shutdown complete (mysqld 8.0.32)  Homebrew.
Warning: The post-install step did not complete successfully
You can try again using:
  brew postinstall mysql
==> 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 -u root

To start mysql now and restart at login:
  brew services start mysql
==> Summary
🍺  /usr/local/Cellar/mysql/8.0.32: 317 files, 298.8MB
==> Running `brew cleanup mysql`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /usr/local/Cellar/mysql/8.0.27_1... (304 files, 294MB)
==> Caveats
==> mysql
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

To start mysql now and restart at login:
  brew services start mysql

启动mysql – 如果报错

chenfubao@chenfubaodeMacBook-Pro /etc % sudo mysql.server start
Starting MySQL
.Logging to '/var/log/mysql/error.log'.
 ERROR! The server quit without updating PID file (/usr/local/var/mysql/chenfubaodeMacBook-Pro.local.pid).
chenfubao@chenfubaodeMacBook-Pro /etc % cd /var/log/mysql/

mysql 启动报错解决

cd /usr/local/var
sudo rm -rf mysql
mysqld --initialize-insecure

再次启动mysql – 启动成功

chenfubao@chenfubaodeMacBook-Pro mysql % sudo mysql.server start
Starting MySQL
 SUCCESS!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值