mysql資料庫密碼重設的方法

來源:互聯網
上載者:User

標籤:mysql   伺服器   重設密碼   資料庫   

一,停掉mysql服務

# service mysqld stop

二,修改mysqld_safe的參數

# mysqld_safe --skip-grant-tables --skip-networking

參數解釋:

--skip-grant-tables: 繞過授權表,這樣就可以在登入mysql時暫時不要求輸入密碼。

--skip-networking: 不要求輸入密碼即可登入mysql伺服器可能會存在安全延緩,因此最好將網路功能關閉。

三,啟動mysql服務

# service mysqld start

這樣就可以直接登入mysql伺服器了

# mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.5.42-log Source distributionType ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the buffer.mysql>

四,修改mysql登入密碼

mysql>  UPDATE user SET PASSWORD=PASSWORD(‘123456‘) WHERE User=‘root‘ AND Host=‘127.0.0.1‘;mysql>  UPDATE user SET PASSWORD=PASSWORD(‘123456‘) WHERE User=‘root‘ AND Host=‘localhost‘;mysql> FLUSH PRIVILEGES;

五,把mysqld_safe的參數改回來

# service mysqld stop# mysqld_safe &# service mysqld start# mysqlERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)



補充:

mysql使用者密碼修改的常用方法:

1、# mysqladmin -u root -h 127.0.0.1 password ‘123456‘ -p2、mysql> SET PASSWORD FOR ‘root‘@‘localhost‘=PASSWORD(‘123456‘); 3、mysql> UPDATE mysql.user SET PASSWORD=PASSWORD(‘123456‘) WHERE User=‘root‘ AND Host=‘localhost‘;


本文出自 “linux營運” 部落格,請務必保留此出處http://hld1992.blog.51cto.com/10543286/1696581

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.