Mac-brew install mysql
阿新 • • 發佈:2020-07-29
查詢並確定自己需要安裝的版本
brew search mysql
==> Formulae
automysqlbackup mysql-connector-c mysql@5.5
mysql mysql-connector-c++ mysql@5.6
mysql++ mysql-sandbox mysql@5.7 ✔
mysql-client mysql-search-replace mysqltuner
mysql-cluster mysql-utilities
==> Casks
mysql-connector-python mysql-utilities navicat-for-mysql
mysql-shell mysqlworkbench sqlpro-for-mysql
安裝[email protected]
#指定版本安裝
brew install mysql@5.7
#配置環境變數
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
#啟動服務
mysql.server start
brew services start mysql@5.7
#初始化,設定密碼
mysql_secure_installation
[root@zhangMySQL5711 bin]# mysql_secure_installation
Enter password:
Securing the MySQL server deployment.
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? //提示安裝密碼驗證外掛
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy: //三個等級的驗證策略
LOW Length >= 8 //最小長度大於等於8個字元
MEDIUM Length >= 8, numeric, mixed case, and special characters //數字,字母,特殊字元 混合,具體的應該是至少1個數字,1個字母,1個特殊字元,長度不超過32個字元
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file // 最嚴格,加上了,字典檔案
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 //這裡我選擇2 MEDIUM
Using existing password for root.
Estimated strength of the password: 50 //這裡也是密碼強度的評級
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
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 //提示要使用剛剛輸入的密碼嗎?
... Failed! Error: Your password does not satisfy the current policy requirements //外掛驗證不通過,不符合當前安全要求級別
New password: //密碼
Re-enter new password:
Estimated strength of the password: 100
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, //預設情況下,MySQL有一個匿名使用者,
allowing anyone to log into MySQL without having to have //這個匿名使用者,不必有一個使用者為他們建立,匿名使用者允許任何人登入到MySQL,
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 //一般情況下,root使用者只允許使用"localhost"方式登入,
'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) : n //
... skipping.
By default, MySQL comes with a database named 'test' that //預設情況下,MySQL資料庫中有一個任何使用者都可以訪問的test庫,
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
- 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.
All done!