In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "the method of user management in mysql". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the method of user management in mysql".
1. Maintenance of root user password:
Since MySQL automatically provides a root user without a password after installing MySQL, set a password for root for security reasons:
# mysqladmin-u root password 123 (123 is the password, or can be written as: '123' or '123')
After setting the password, you cannot enter mysql directly when you log in. You must follow some parameters, as follows:
[root@localhost ~] # mysql-u root-p (- u followed by the login user name,-p prompts for password login)
Enter password: (enter password)
Change the password:
[root@localhost ~] # mysqladmin-u root-p password 123456 (password followed by a new password to be updated)
Enter password: (enter the original password and press enter)
Some people will ask: day! What if my original mysql password is lost (in fact, there are usually two kinds of irresponsible administrator and one hacker)?
The method I use:
Find the mysqld_safe file in the mysql installation directory,. / mysqld_safe-- skip-grant-tables
Then a password-free environment is started:
Mysql-u root
Mysql > update mysql.user set password = password ('red') where User='root'
Mysql > flush privileges
Myusql > quit
Over, of course, someone said that you can add-- skip-grant-tables to the configuration file.
II. Maintenance of ordinary users
Add one user:
1. Use CREATE USER statement to create a new ordinary user
User01 can only log in locally
CREATE USER user01@'localhost' IDENTIFIED BY 'password1'
User02 can be accessed remotely
CREATE USER user02@'%' IDENTIFIED BY 'password1'; where% is a wildcard, which means that the user can log in to mysql anywhere.
In ROOT
Permission to modify user01 password SET PASSWORD FOR 'user01'@'localhost' = PASSWORD (' password2')
If you report an error sometimes, please remember to add @ host, because the default @ is followed by%, so you can't find this user if you localhost.
2. Use insert statement to create a new ordinary user
Insert into mysql.user (Host,User,Password) values ("localhost", "yusuhan", password ("123"))
Flush privileges
Explanation: the user in the mysql database stores all users and their permissions. The above is inserted in the user table, user, password, where the host comes from, and then you have to flush privileges; but can't use why'?. There is no authority! Grant all on *. * to xxx@localhost identified by '123 "; granting permissions to this user!
3. Create a new ordinary user with the Grant statement
Grant all on *. * to xxx@ "%" identified by "123"
Give xxx the ability to log in to the database on any host and operate anything, basically like root.
Have you seen this user select user from mysql.user?
Analysis: if you create a user, and give him certain permissions, generally use grand, other methods can not be achieved in one step. What do you say?
Delete a user? .
DROP USER 'allmusic@'localhost';-drop user: allmusic.
You still want to add Localhost. The default is%.
Delete from user where user='allmusic' and host='localhost'
Flush privileges
Thank you for your reading, the above is the content of "user Management methods in mysql". After the study of this article, I believe you have a deeper understanding of the management methods of users in mysql, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.