Mysql grant permission assignment password modification www.2cto.com 1. Modify mysql-u root-p in the database and press enter to enter the password mysql> user mysql> select user, password from user; # view the PASSWORD # The PASSWORD is 41 BITs. It is not recommended to directly modify this table, but you can use function compute to change the PASSWORD for mysql> select PASSWORD ('abc '); www.2cto.com # change the password to the calculated value based on the specific conditions. Be careful. [C] mysql-u root-p press enter to enter the password mysql> user mysql> select user, password from user; # view the password #41 digits of the password can be seen, directly modifying this table is not the best practice, but you can use the function compute PASSWORD to modify mysql> select PASSWORD ('abc '); # Be careful when changing the password to the calculated value based on specific conditions. 2. In the command line, change the root PASSWORD to yourpassword mysqladmin-u root-p PASSWORD yourpassword and press enter to enter the original PASSWORD [c] mysqladmin-u root-p PASSWORD yourpassword. Press enter to enter the original PASSWORD. 3. Use set password, FOR example, change the Local PASSWORD of root to yourpasswd: mysql> set password for root @ localhost = PASSWORD ('yourpasswd '); [c] mysql> set password for root @ localhost = PASSWORD ('yourpasswd'); 4. Use GRANT... IDENTIFIED. For example, change the root password to youpassword: mysql> grant usage on *. * TO root @ localhost identified by 'yourpassword'; grant permission on database objects to users 1. grant normal data users the right TO query, insert, update, and delete all table data in the database. Grant select on testdb. * to common_user @ '%' grant insert on testdb. * to common_user @ '%' grant update on testdb. * to common_user @ '%' grant delete on testdb. * to common_user @ '% or use a MySQL command to replace: grant select, insert, update, delete on testdb. * to common_user @ '%' 2. grant the database developer to create tables, indexes, views, stored procedures, and functions.... Grant permissions to create, modify, and delete MySQL Data Table structures. Grant create on testdb. * to developer @ '2017. 168.0.% '; grant alter on testdb. * to developer @ '2017. 168.0.% '; grant drop on testdb. * to developer @ '2017. 168.0.% '; MySQLgrant permission to operate MySQL Foreign keys. Grant references on testdb. * to developer @ '192. 192.% '; grant the temporary table permission for MySQL. Grant create temporary tables on testdb. * to grant permission to operate MySQL indexes. Grant index on testdb. * to grant permissions to operate the MySQL view and view the source code. Grant create view on testdb. * to developer @ '2017. 168.0.% '; grant show view on testdb. * to developer @ '2017. 168.0.% '; grant permissions to operate MySQL stored procedures and functions. Grant create routine on testdb. * to developer @ '2017. 168.0.% '; -- now, can show procedure status grant alter routine on testdb. * to developer @ '2017. 168.0.% '; -- now, you can drop a procedure grant execute on testdb. * to developer @ '2017. 168.0.% '; 3. grant common DBA permission to manage a MySQL database. MySQLgrant all privileges on testdb to, where the keyword "privileges" can be omitted. Grant execute on procedure testdb. pr_add to 'dba '@ 'localhost' grant execute on function testdb. fn_add to 'dba '@ 'localhost' grant all on *. * to dba @ 'localhost' v. MySQL grant permissions can be applied to multiple levels. 1. grant applies to the entire MySQL Server: grant select on *. * to dba @ localhost; -- dba can query tables in all databases in MySQL. Grant all on *. * to dba @ localhost; -- dba can manage all databases in MySQL. 2. grant works on a single database: grant select on testdb. * to dba @ localhost; -- dba can query tables in testdb. 3. grant applies to a single data table: grant select, insert, update, delete on testdb. orders to 4. grant is applied to columns in the Table: grant select (id, se, rank) on testdb. apache_log to 5. mySQL grant is used in stored procedures and functions: grant execute on procedure testdb. pr_add to 'dba '@ 'localhost' grant execute on function testdb. fn_add to 'dba '@ 'localhost' 6. View MySQL user permissions view current user permissions: show grants; view other MySQL user permissions: show grants for dba @ localhost; 7. revoke permissions granted to My SQL user permission. The revoke syntax is similar to that of grant. You only need to replace the keyword "to" with "from": grant all on *. * to dba @ localhost; revoke all on *. * from dba @ localhost; 8. Considerations for MySQL grant and revoke User Permissions 1. grant and revoke permissions can only take effect after the user reconnects to the MySQL database. 2. If you want to authorize the user, you can also grant these permissions to other users. You need to select "grant option" grant select on testdb. * to dba @ localhost with grant option;