Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set password for users in MySQL database

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

MySQL database how to set passwords for users, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

How to set password for users under MySQL database

First we should know that the password store in the Mysql database must be encrypted with the password () function. Because passwords are stored in the user table in encrypted form, not as plain text. If you don't have encryption, execute the following statement directly in the database:

Usemysql

Insertintouser (host,user,password) values ('%', 'user_name','yourpassword')

Flushprivileges

I believe the result will not satisfy you. Because the server compares encrypted values, the server connection must fail. What needs to be noted here is that the command flushprivileges; reloads the authorization table. You can also use mysqladmin-urootreload or mysqladmin-urootflush-privileges directly under shell to reload the authorization table.

How to set password for users under MySQL database

In the Mysql environment, you can use the following statement to set the password:

1.insertintouser (host,user,password) values ('%', 'user_name',password ("yourpassword")

2.setpasswordforuser_name=password ("yourpassword")

Both of the above methods must overload the authorization table.

3. Of course, you can also set the password directly when you create a user, and the grant statement will automatically encrypt the password for you.

Such as: grantallon*.*touser_name@%identifiedby "yourpassword"

In addition, you can also use the mysqladmin program to set the password in the shell environment

Such as: mysqladmin-urootpassword "yourpassword"

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report