Mac-brew install mysql


查找並確定自己需要安裝的版本

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

安裝msyql@5.7

#指定版本安裝
brew install mysql@5.7

#配置環境變量
echo 'export PATH="/usr/local/opt/mysql@5.7/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! 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM