Mac下新安裝的MySQL無法登陸root使用者解決方案

來源:互聯網
上載者:User

標籤:

 一 設定MySQL命令列搜尋路徑0.蘋果->系統喜好設定->最下邊點mysql 在彈出頁面中 啟動mysql服務1.開啟終端,輸入:sudo vi ~/.bash_profile 如果已存在刪除:  sudo rm -rf .bash_* 2.輸入 i 3.然後粘貼以下內容# mysqlalias mysql=‘/usr/local/mysql/bin/mysql‘alias mysqladmin=‘/usr/local/mysql/bin/mysqladmin‘# lsalias ls=‘ls -G‘ 4.按ESC鍵5.輸入 :wq6.重新啟動終端程式   二 Mac下新安裝的MySQL無法登陸root使用者解決方案

在Macbook Pro上安裝好MySQL後,執行mysqladmin設定root帳號的密碼時,報錯

mysqladmin: connect to server at ‘localhost‘ failed

error: ‘Access denied for user ‘root‘@‘localhost‘ (using password: NO)‘

 

 

1:蘋果->系統喜好設定->最下邊點mysql 在彈出頁面中 關閉mysql服務

2:進入終端
輸入:cd /usr/local/mysql/bin

3.斷行符號後 登入管理員權限
  sudo su
4.斷行符號後輸入以下命令來禁止mysql驗證功能
  ./mysqld_safe --skip-grant-tables &

--skip-grant-tables:不啟動grant-tables(授權表),跳過許可權控制。

--skip-networking :跳過TCP/IP協議,只在本機訪問(這個選項不是必須的。可以不用)

 

5.修改密碼:

mysql>  update mysql.user set authentication_string=PASSWORD(‘123456‘) where user=‘root‘;

mysql> flush privileges;

 

 

 

 

 

Mac下新安裝的MySQL無法登陸root使用者解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.