In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to add new users to MYSQL. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
1. New user
/ / Log in to MYSQL
@ > mysql-u root-p
@ > password
/ / create a user
Mysql > insert into mysql.user (Host,User,Password) values ('localhost','jeecn',password (' jeecn'))
/ / refresh the system permissions table
Mysql > flush privileges
This creates a user named: jeecn password: jeecn.
/ / log in after you log out
Mysql > exit
@ > mysql-u jeecn-p
@ > enter your password
Mysql > Login succeeded
two。 Authorize the user
/ / Log in to MYSQL (with ROOT permission). I log in as ROOT.
@ > mysql-u root-p
@ > password
/ / first create a database (jeecnDB) for the user
Mysql > create database jeecnDB
/ / authorized jeecn users have all permissions of the jeecn database
@ > grant all privileges on jeecnDB.* to jeecn@localhost identified by 'jeecn'
/ / refresh the system permissions table
Mysql > flush privileges
Mysql > other actions
/ / if you want to assign some permissions to a user, you can write as follows:
Mysql > grant select,update on jeecnDB.* to jeecn@localhost identified by 'jeecn'
/ / refresh the system permission table.
Mysql > flush privileges
Mysql > grant permission 1, permission 2, … Permission n on database name. Table name to user name @ user address identified by 'connection password'
Permission 1, permission 2,... Permission n represents 14 permissions such as select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file.
When permission 1, permission 2,... Permission n is replaced by all privileges or all, which means that the user is given full permissions.
When the database name. The table name is replaced by *. *, which gives the user permission to manipulate all tables in all databases on the server.
The user address can be localhost, ip address, machine name, domain name. You can also use'%'to indicate a connection from any address.
The connection password cannot be empty, otherwise the creation fails.
For example:
Mysql > grant select,insert,update,delete,create,drop on vtdc.employee to jee@10.163.225.87 identified by '123'
Assign the user jee from 10.163.225.87 the right to select,insert,update,delete,create,drop and other operations on the employee table of the database vtdc, and set the password to 123.
Mysql > grant all privileges on vtdc.* to jee@10.10.10.87 identified by '123'
Assign user jee from 10.163.225.87 permissions to perform all operations on all tables in the database vtdc, and set the password to 123.
Mysql > grant all privileges on *. * to jee@10.10.10.87 identified by '123'
The user jee from 10.163.225.87 is assigned permissions to perform all operations on all tables in all databases, and the password is set to 123.
Mysql > grant all privileges on *. * to jee@localhost identified by '123'
Assign the local user jee permission to perform all operations on all tables in all databases and set the password to 123.
3. Delete user
@ > mysql-u root-p
@ > password
Mysql > DELETE FROM user WHERE User= "jeecn" and Host= "localhost"
Mysql > flush privileges
/ / Delete the user's database
Mysql > drop database jeecnDB
4. Modify the specified user password
@ > mysql-u root-p
@ > password
Mysql > update mysql.user set password=password ('new password') where User= "jeecn" and Host= "localhost"
Mysql > flush privileges
Mysql > quit
This is the end of the article on "how to add new users to MYSQL". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.