如何修改MySQl資料庫的root密碼

來源:互聯網
上載者:User

修改MySQl資料庫的root密碼可以通過以下幾種方式來進行:

一、在已知MYSQL資料庫的ROOT使用者密碼的情況下,修改密碼的方法:

1、在SHELL環境下,使用mysqladmin命令設定:mysqladmin –u root –p password “新密碼”斷行符號後要求輸入舊密碼

2、在mysql>環境中,使用update命令,直接更新mysql庫user表的資料:

Update mysql.user set password=password(‘新密碼’) where user=’root’;

flush  privileges;

注意:mysql語句要以分號”;”結束

3、在mysql>環境中,使用grant命令,修改root使用者的授權許可權。

grant all on*.*to root@’localhost’ identified by‘新密碼’;

二、如查忘記了mysql資料庫的ROOT使用者的密碼,又如何做呢?方法如下:

1、關閉當前啟動並執行mysqld服務程式:service  mysqld  stop(要先將mysqld添加為系統服務)

2、使用mysqld_safe指令碼以安全模式(不載入授權表)啟動mysqld 服務

/usr/local/mysql/bin/mysqld_saft  --skip-grant-table&

直接斷行符號即可。

3、使用空密碼的root使用者登入資料庫,重新設定ROOT使用者的密碼

#mysql-u root

Mysql> Update mysql.user set password=password(‘新密碼’) where user=’root’;

Mysql> flush privileges;

查看本欄目更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/database/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.