亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

修改mysql賬戶密碼

標簽:
MySQL

Summary: in this tutorial you will learn how to change or reset password for MySQL account in various ways by using the UPDATESET PASSWORD and GRANT statements.

Before changing the password, there are some points that you should consider:

  • Which user do you want to change the password?

  • What host, which the user connects to, you want to change the password?

  • Have you been aware of the related applications that are currently using the MySQL account whose password is being changed?If you change the password without proper planning, those applications will lose the connection to the database and stop functioning properly.

MySQL provides several statements that you can use to change or reset password of a MySQL account including UPDATE statement, SET PASSWORD statement and GRANT USAGE statement.

MySQL changing password using UPDATE statement

The first way to change the password is to use the UPDATE statement to update the User and Host column of the user table in the mysql database. After executing the UPDATE statement, you need to execute the FLUSH PRIVILEGES statement to reload privileges from the grant table in the mysql database.

Suppose you want to change the password for OutOfMemory user that connect from the  OutOfMemory.CN host to Secret1970, you need to execute the following statements:

USE mysql; UPDATE user  SET password = PASSWORD('Secret1970') WHERE user = 'OutOfMemory' AND        host = 'OutOfMemory.CN'; FLUSH PRIVILEGES;

It is important to note that we’ve used the PASSWORD() function to encrypt the plain text password. The following example demonstrates how the PASSWORD() function encrypts a plain text password.

SELECT PASSWORD('Secret1970') AS encrypt_password

 

*16A54B5EE15C823362FAE7F64409A8F8C8501DD6

 

MySQL changing password using SET PASSWORD statement

The second way to change the password is by using the SET PASSWORD statement. You use the MySQL account in  user@host format to update the password. If you need to change password for other accounts, you need to have at least UPDATE privilege. You don’t need to execute the FLUSH PRVILILEGES statement to reload privileges from grant table.

The following statement change password of OutOfMemory account by using the SET PASSWORD statement.

SET PASSWORD FOR 'mysqltutorail'@'OutOfMemory.CN' = PASSWORD('Secret1970')

 

MySQL changing password using GRANT USAGE statement

The third way to change the password is by using the GRANT USAGE statement with the IDENTIFIED BY clause. In this way, you specify the password in plain text instead of the encrypted from.

The following statement changes the password of OutOfMemory account by using the GRANT USAGE statement:

GRANT USAGE ON *.* TO [email protected] IDENTIFIED BY Secret1970

In case you want to reset the MySQL root account’s password, you need to force the MySQL database server to stop and restart without using grant table validation.

In this tutorial, we introduced you to some handy MySQL statements that allows you to change MySQL accounts password.

Related Tutorials

原文链接:http://outofmemory.cn/mysql/administration/mysql-changing-password

點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消