Mac安裝mysql8.1.2,且支援客戶端登入
Mac安裝mysql8版本會遇到不少的坑,大家可以用如下方式解決:
1、用brew安裝最新版本的mysql,我安裝的時候還是8.1.2
brew install mysql
2、開啟mysql服務
brew services start mysql
3、安裝安全外掛,即為mysql的root帳號生成密碼
mysql_secure_installation
3.1
Securing the SQL/">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,開啟密碼元件
3.2
There are three levels of password validation policy:
LOWLength >= 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
3.3
Please set the password for root here.
New password:
Re-enter new password:
這一步是輸入密碼和確認密碼
3.4
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :
輸入y,確認提交密碼
3.5
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,刪除匿名使用者
3.6
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) :
如果要禁止root遠端登入,可以選yes,否則選no。本地的話,我建議選no吧。
3.7
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,刪除test資料庫,我們自己建其他庫就是了
3.8
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就是了
好了,以上操作完之後,就為root建立了一個密碼了。
4、此時你興致勃勃的去Sequal pro登入(或其他客戶端),此時會提示
Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found
說明客戶端不支援這種加密方式,因為預設生成的root的密碼是用 caching_sha2_password 外掛加密的。而客戶端找不到 caching_sha2_password 外掛,於是登入不上。
4.1 我們先通過終端輸入:mysql -u root -p登入mysql,然後mysql>use mysql
4.2 CREATE USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY '12345678'(按照配置的安全等級來,我配置的0,所以只要滿足8位以上就可以了);
好了,以上操作完之後,客戶端就可以登入mysql了。
如在安裝過程中遇到問題,請聯絡我(qq:378439929)
本文版權歸逍遙jc所有,轉載請註明來源,謝謝合作。