Mysql creates and deletes root users and common users, and modifies and deletes root users.
Method 1: use the set password command
mysql -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
Method 2: Use mysqladmin
mysqladmin -u root password "newpass"
If the root user has set a password, use the following method:
mysqladmin -u root password oldpass "newpass"
Method 3: Use UPDATE to directly edit the user table
mysql -u root mysql> use mysql; mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root'; mysql> FLUSH PRIVILEGES;
Create a common user
User Management
mysql>use mysql;
View
mysql> select host,user,password from user ;
Create
Mysql>
User Management
mysql>use mysql;
View
mysql> select host,user,password from user ;
Create user
mysql> insert into mysql.user (Host,User,Password) Values('%','wise',PASSWORD('passwd'));msyql>FLUSH RPIVILEGES
Modify
Mysql> rename user feng to newuser; // mysql 5 can be used later. You must use update to update the user table before.
Delete
Mysql> drop user newuser; // When deleting a user before mysql5, you must first use revoke to delete the user permission and then delete the user. After mysql5, you can drop the command to delete the user's permissions while deleting the user.
Change Password
mysql> set password for zx_root =password('xxxxxx'); mysql> update mysql.user set password=password('xxxx') where user='otheruser'
View User Permissions
mysql> show grants for zx_root;
Grant Permissions
mysql> grant all privileges on YQ.* to wise;
Revoke permissions
Mysql> revoke select on dmc_db. * from zx_root; // if the permission does not exist, an error is returned.
Modify
Mysql> rename user feng to newuser; // mysql 5 can be used later. You must use update to update the user table before.
Delete
Mysql> dropuser newuser; // When deleting a user before mysql5, you must first use revoke to delete the user permission and then delete the user. After mysql5, you can drop the command to delete the user's permissions while deleting the user.
Change Password
mysql> set password for zx_root =password('xxxxxx'); mysql> update mysql.user set password=password('xxxx') where user='otheruser'
View User Permissions
mysql> show grants for zx_root;
Grant Permissions
mysql> grant select on dmc_db.* to zx_root;
Revoke permissions
Mysql> revoke select on dmc_db. * from zx_root; // if the permission does not exist, an error is returned.
The above section describes how to create root users and common users and modify and delete functions for mysql. I hope this will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!