MacBook 中homebrew安裝mysql完整教程
阿新 • • 發佈:2019-01-11
brew install mysql 過程解析
安裝brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安裝mysql
brew install mysql
安裝完成提示如下:
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.21.sierra.bottle.
################################################ ######################## 100.0%
==> Pouring mysql-5.7.21.sierra.bottle.tar.gz
==> /usr/local/Cellar/mysql/5.7.21/bin/mysqld --initialize-insecure --user=xuemi
==> 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
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don' t want/need a background service you can just run:
mysql.server start
==> Summary
�� /usr/local/Cellar/mysql/5.7.21: 323 files, 233.9MB
注意:
- 如果提示如下:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
說明mysql服務沒有啟動需要執行:
mysql.server start
出現以下提示,說明mysql伺服器啟動完成
Starting MySQL
. SUCCESS!
設定mysql
在終端中執行以下命令:
mysql_secure_installation
出現以下提示:
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
//驗證密碼外掛可以用來測試密碼和提高安全性。它檢查密碼的強度,並允許使用者只設置那些足夠安全的密碼。你願意安裝驗證密碼外掛嗎?
VALIDATE PASSWORD PLUGIN 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 plugin?
//在下邊的問題中輸入y或者Y,輸入其他的都表示為否
Press y|Y for Yes, any other key for No:y
// 密碼驗證策略有三個級別:
// 低長度> = 8
// 中長度>= 8,數字,混合情況,和特殊字元。
// 強長度>= 8,數字,混合情況,特殊字元和字典檔案。
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
// 0,1,2分別代表3個不同的級別,看自己的生產環境需要的密碼需求
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:0
// 請在這裡設定root的密碼。
// 新密碼:
// 重新輸入新密碼:
// 估計密碼強度:50。
// 您希望繼續提供密碼嗎?(請按y| y為Yes,任何其他關鍵字):
Please set the password for root here.
New password:
Re-enter new password:
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
// 預設情況下,MySQL安裝有匿名使用者,
// 允許任何人在不需要的情況下登入MySQL。
// 為它們建立的使用者帳戶。這僅僅是為了。
// 測試,並使安裝更加順利。
// 在開始生產之前,你應該把它們去掉。
// 環境。
// 刪除匿名使用者?(請按y| y為Yes,任何其他關鍵字):
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
// 成功。
// 通常,根應該只允許連線。
// “localhost”。這確保了某人無法猜測。
// 來自網路的根密碼。
// 不允許遠端root登入嗎?(請按y| y為Yes,任何其他關鍵字):
// 這裡表示是否允許遠端登入root使用者,我這裡是測試環境,選擇鍵入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.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) :y
成功。
// 預設情況下,MySQL附帶一個名為“test”的資料庫。
// 任何人都可以訪問。這也只用於測試,
// 在開始生產之前應該將其移除。
// 環境。
// 這裡提示是否刪除mysql的test資料庫
刪除測試資料庫並訪問它?(請按y| y為Yes,任何其他關鍵字):
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.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) :y
// ——刪除測試資料庫……
// 成功。
// -刪除測試資料庫上的特權…
// 成功。
// 重新載入特權表將確保所有更改。
// 到目前為止,將立即生效。
// 現在重新載入許可權表嗎?(請按y| y為Yes,任何其他關鍵字):
- 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.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :y
Success.
//出現此訊息,說明mysql設定成功,請牢記輸入的mysql密碼
All done!
登入mysql進行測試
mysql -u root -p