mac下修改mysql的密碼

來源:互聯網
上載者:User

標籤:tar   輸入   啟動mysql   root   localhost   帳號   targe   運行   div   

第一種mysql版本:5.7.171.首先我們要關閉mysql服務sudo /usr/local/mysql/support-files/mysql.server stop2.我們要用安全模式啟動mysqlsudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables3.使用root帳號登入mysql服務/usr/local/mysql/bin/mysql u root4.修改root帳號的密碼(其實這啟動並執行是sql語句)update mysql.user set authentication_string=password(‘qingyun1‘) where user=‘root‘ and Host = ‘localhost‘;如果有必要,建議運行一下:flush privileges;5.關閉安全模式,正常的重啟mysqlsudo /usr/local/mysql/support-files/mysql.server restart6.正常的使用root帳號和密碼串連mysql/usr/local/mysql/bin/mysql -u root -p第二種
如果忘記密碼,強行修改:1:?停止Mysql服務 sudo /usr/local/mysql/support-files/mysql.server stop2:?進入終端輸入:cd /usr/local/mysql/bin/?斷行符號後;登入管理員權限 sudo su?斷行符號後;輸入以下命令來禁止mysql驗證功能./mysqld_safe --skip-grant-tables &?斷行符號後mysql會自動重啟(喜好設定中mysql的狀態會變成running)3. ? 輸入命令 ./mysql?斷行符號後,輸入命令 FLUSH PRIVILEGES;  ?斷行符號後,輸入命令 ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘你的新密碼‘;第三種
1.  停止 mysql server.  通常是在 ‘系統喜好設定‘ > MySQL > ‘Stop MySQL Server‘或者:sudo /usr/local/mysql/support-files/mysql.server stop2.  開啟終端,輸入:     sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables3.  開啟另一個新終端,輸入:     sudo /usr/local/mysql/bin/mysql -u root    UPDATE mysql.user SET authentication_string=PASSWORD(‘新密碼‘) WHERE User=‘root‘;     FLUSH PRIVILEGES;     \q4.  重啟sudo /usr/local/mysql/support-files/mysql.server restart*以上方法針對  mysql V5.7.9, 舊版的mysql請使用:UPDATE mysql.user SET Password=PASSWORD(‘新密碼‘) WHERE User=‘root‘;    這三種方法可以根據情況使用!

mac下修改mysql的密碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.