mac使用brew安裝mysql
阿新 • • 發佈:2018-10-27
ring lib erro rem 設置密碼 ont numeric 默認 輸入
1、安裝mysql
#brew install mysql
報錯
Error: The following directories are not writable by your user:
/usr/local/lib
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/lib
意思是 您應該將這些目錄的所有權更改為您的用戶
執行以下命令設置權限
#sudo chown -R wuj /usr/local/lib
然後重新安裝即可 brew install mysql
2、啟動mysql服務
#mysql.server start
3、設置密碼
通過brew安裝後默認密碼為空
執行以下命令設置密碼
#mysql_secure_installation
Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD COMPONENT 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 component? Press y|Y for Yes, any other key for No: y 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 Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
之後輸入密碼強度 0、1、2選擇一個
因為手誤我選擇了1,但在後面設置密碼時無法設置簡單密碼
Estimated strength of the password: 25
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
解決
更改密碼強度為 LOW
先登錄mysql
#mysql -uroot
設置validate_password_policy為0(表示等級low)
set global validate_password_policy=0;
執行會報錯
ERROR 1193 (HY000): Unknown system variable ‘validate_password_policy‘
原因是 MySQL 5.7和MySQL 8.0版本變量名不同
validate_password_policy是在版本 MySQL 5.7中 存在 ,而 MySQL 8.0不存在
解決,執行以下命令查看密碼驗證插件
SHOW VARIABLES LIKE ‘validate_password%‘;
Variable_name | Value |
+--------------------------------------+--------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1
可以看到在mysql8.0中 變量名 為 validate_password.policy
好了,修改變量名後執行設置成功
set global validate_password.policy=0;
除此之外 ,還需設置密碼長度(默認是長度8位以上)
set global validate_password.length=4;
解決以上問題後再次執行以下命令,設置密碼即可
#mysql_secure_installation
4、mysql登錄驗證
#mysql -uroot -p
顯示數據庫
#show databases;
另:
在php連接數據庫時報錯,無法連接到數據庫
The server requested authentication method unknown to the client
發現是因為mysql8.0版本的問題
打開mysql數據庫 -》用戶-》編輯root用戶修改
修改插件 caching_sha2_password為 mysql_native_password即可
參考
https://blog.csdn.net/maxsky/article/details/51171474
https://blog.csdn.net/HaHa_Sir/article/details/80552663
mac使用brew安裝mysql