·首先下載mysql,鏈接:www.mysql.com  點擊DOWNLOADS->Community->MySQL Community Server

·安裝之后打開偏好設置

 

·點擊MySQL,開啟mysql

 

·在終端中輸入mysql路徑:

PATH="$PATH":/usr/local/mysql/bin

 

·在終端登錄到MySQL的命令如下:

mysql -u root -p

 

如果顯示的內容如下,即是已經成功登錄到MySQL服務:

 

 

·展示mysql的端口

show global variables like 'port';

 

2.navicat鏈接mysql

首先下載Navicat for MySQL,史蒂芬周上有,下載后打開

 

如果遇到這種情況 MySQL said: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2): image not found
解決方案:
  1. 打開系統偏好設置,找到mysql,點擊Initialize Database。
  2. 輸入你的新密碼,記住這個密碼,用於后期鏈接數據庫的登陸使用。
  3. 選擇‘Use legacy password‘。
  4. 重啟mysql服務。
  5. 使用sequel Pro鏈接。

在重新鏈接就好了