Linux environment Mysql create new users and databases and authorize
1. Log in to mysql
# mysql-u root-p
two。 New users
Insert into mysql.user (Host,User,Password) values ("localhost", "xxx", password ("*"))
Note: xxx is the new user name, and * * is the user password.
3. After executing this sentence, you also need to refresh the permission table
Flush privileges
4. Create a new database and grant user permissions
Create database dbtest
Full authorization:
Allow local login
Grant all privileges on dbtest.* to xxx@localhost identified by "*"
Allow any host to log in
Grant all privileges on dbtest. To xxx@'%' identified by ""
Partial authorization:
Grant select,update on dbtest.* to xxx@localhost identified by "* *"
5. Permission is granted, and the permission table needs to be refreshed.
Flush privileges
6. Query the new results through the sql statement
Select user,host,password from mysql.user
7. Delete user
Delete from user where user='xxx'
Flush privileges
8. Delete database
Drop database dbtest
9. Modify the password
Update mysql.user set password=password ('new password') where User='xxx' and Host='localhost'
Flush privileges