sierra mysql_macOS High Sierra 使用 Homebrew 安装 MYSQL 5.7
首先我們需要安裝 Homebrew 包管理器,在開始之前請(qǐng)確保你的Mac已經(jīng)安裝了 Xcode,當(dāng)然了,如果你沒有安裝Xcode,Homebrew會(huì)在安裝過程中提示(強(qiáng)迫)你安裝Xcode Command Line Tools。
# 安裝 homebrew,是的你沒看錯(cuò),在終端里粘貼以下命令即可
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安裝會(huì)毫無樂趣的自動(dòng)進(jìn)行,中間會(huì)提醒你輸入系統(tǒng)密碼。
講真,homebrew 是一款非常良心的包管理器,它會(huì)在你絕望的時(shí)候通過一條命令搞定很多事情我就不再詳細(xì)描述了。
安裝MYSQL之前,我們先看一下由homebrew管理的MYSQL包是什么版本。
# 執(zhí)行以下命令,查看MYSQL包的情況
? ~ brew info mysql
mysql: stable 5.7.19 (bottled)
Open source relational database management system
https://dev.mysql.com/doc/refman/5.7/en/
Conflicts with:
mariadb (because mysql, mariadb, and percona install the same binaries.)
mariadb-connector-c (because both install plugins)
mysql-cluster (because mysql, mariadb, and percona install the same binaries.)
mysql-connector-c (because both install MySQL client libraries)
percona-server (because mysql, mariadb, and percona install the same binaries.)
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb
==> Dependencies
Build: cmake ?
Required: openssl ?
==> Requirements
Required: macOS >= 10.7 ?
==> Options
--with-archive-storage-engine
Compile with the ARCHIVE storage engine enabled
--with-blackhole-storage-engine
Compile with the BLACKHOLE storage engine enabled
--with-debug
Build with debug support
--with-embedded
Build the embedded server
--with-local-infile
Build with local infile loading support
--with-test
Build with unit tests
==> Caveats
We've installed your MySQL database without a root password. To secure it run:mysql_secure_installationMySQL is configured to only allow connections from localhost by defaultTo connect run:mysql -urootTo have launchd start mysql now and restart at login:brew services start mysqlOr, if you don't want/need a background service you can just run:
mysql.server start
從以上一大坨信息中,我們大致可以明白以下幾點(diǎn):
1. MYSQL的版本是 5.7.19
2. 它存在一些沖突包,沒有辦法和他們共存
3. 安裝后默認(rèn)是沒有密碼的,如果你想安全一點(diǎn),可以執(zhí)行 mysql_secure_installation 來進(jìn)行引導(dǎo)安全設(shè)置
4. 你可以將MYSQL設(shè)置為開機(jī)啟動(dòng), brew services start mysql
5. 你也可以每次都手動(dòng)啟動(dòng)或關(guān)閉MYSQL mysql.server start/stop/restart
接下來我們安裝 MYSQL
brew install mysql
# 是的你沒有看錯(cuò),啰嗦了半天其實(shí)只需要在終端里執(zhí)行這一條命令
等待安裝完畢,我們將 MYSQL 服務(wù)設(shè)置為開機(jī)啟動(dòng)
brew services start mysql
重啟 MYSQL 服務(wù)
brew services restart mysql
關(guān)閉 MYSQL 服務(wù)
brew services stop mysql
查看 MYSQL 服務(wù)狀態(tài)
brew services list
另外,由于默認(rèn)安裝沒有設(shè)置密碼,所以你可以直接登錄,然后設(shè)置 root 密碼
# 登錄
mysql -uroot
# 修改root密碼
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'your-password' WITH GRANT OPTION;
flush privileges;
好了,再退出重新登錄試試看。
總結(jié)
以上是生活随笔為你收集整理的sierra mysql_macOS High Sierra 使用 Homebrew 安装 MYSQL 5.7的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vc2010访问局域网mysql_VC2
- 下一篇: mysql 数据类型 decimal_m