The way Mysql is used, pretty full enough

Source: Internet
Author: User

Http://www.cnblogs.com/fslnet/p/3143344.html


Mysql>use mysql; View mysql> select Host,user,password fromUserCreating mysql> Create User Zx_rootidentifiedBy ' xxxxx '; Identified by will use plaintext password encryption as a hash value to store changes Mysql>rename user Feng to Newuser;//mysql 5, before you need to use Update to update the user table to delete MYSQL&G TDropUser NewUser; MySQL5 before you delete a user, you must first use revoke to remove the user right, and then delete the user, mysql5 after the drop command can remove the user's associated permissions for the user to change the password mysql> set password forZx_root =password (' xxxxxx '); mysql> Update Mysql.user set Password=password (' xxxx ') where user= ' otheruser ' View User rights mysql> show grants for Zx_roo t; Grant permission mysql> GrantSelectOn dmc_db.* toZx_root; Reclaim permissions mysql> revoke select on dmc_db.* from Zx_root; If the permission does not exist, the above command can also be given and reclaimed using multiple permissions, and the permissions are separated by commas using a comma mysql> grantselect,update,delete, insertOn dmc_db.* toZx_root; Use flush privileges if you want to see results immediately; command updateyou must give a message when setting permissions1, to grant permission 2, the database or table 3 that is granted access, the user nameGrant and revoke can control access at several levels1, entire server, using grant all and revoke ALL2, entire database, using on DATABASE.*3, feature table, using on DATABASE.TABLE4, specific column 5, specific stored proceduremeaning of the value of the host column in the user table%Match all hostslocalhostlocalhost will not be parsed into an IP address and connected directly via Unixsocket127.0.0.1is connected via the TCP/IP protocol and can only be accessed natively;:: 1:: 1 is compatible with support IPv6, indicating the same as IPv4 127.0.0.1

Grant normal data user, the right to query, insert, UPDATE, delete all table data in the database.

Grant Select on testdb.* to [email protected] '% '

Grant insert on testdb.* to [email protected] '% '

Grant update on testdb.* to [email protected] '% '

Grant Delete on testdb.* to [email protected] '% '

Alternatively, replace it with a MySQL command:

Grant SELECT, INSERT, UPDATE, delete on testdb.* to [email protected] '% '

9>.grant database developers, creating tables, indexes, views, stored procedures, functions ... and other permissions.

Grant creates, modifies, and deletes MySQL data table structure permissions.

Grant create on testdb.* to [email protected] ' 192.168.0.% ';

Grant ALTER on testdb.* to [email protected] ' 192.168.0.% ';

Grant drop on testdb.* to [email protected] ' 192.168.0.% ';

Grant operates MySQL foreign key permissions.

Grant references on testdb.* to [email protected] ' 192.168.0.% ';

Grant operates MySQL temp table permissions.

Grant create temporary tables on testdb.* to [email protected] ' 192.168.0.% ';

Grant operates MySQL index permissions.

Grant index on testdb.* to [email protected] ' 192.168.0.% ';

Grant operates the MySQL view, viewing the view source code permissions.

Grant CREATE view on testdb.* to [email protected] ' 192.168.0.% ';

Grant Show view on testdb.* to [email protected] ' 192.168.0.% ';

Grant operates MySQL stored procedures, function permissions.

Grant create routine on testdb.* to [email protected] ' 192.168.0.% '; --now, can show procedure status

Grant alter routine on TESTDB.* to [email protected] ' 192.168.0.% '; --now, can drop a procedure

Grant execute on testdb.* to [email protected] ' 192.168.0.% ';

10>.grant the normal DBA to manage permissions for a MySQL database.

Grant all privileges on TestDB to [email protected] ' localhost '

Where the keyword "privileges" can be omitted.

The 11>.grant advanced DBA manages permissions for all databases in MySQL.

Grant all on * * to [email protected] ' localhost '

12>. MySQL grant permissions can be used on multiple levels, respectively.

1. Grant acts on the entire MySQL server:

Grant SELECT On *. * to [email protected]; --DBAs can query tables in all databases in MySQL.

Grant all on * * to [email protected]; --DBA can manage all databases in MySQL

2. Grant acts on a single database:

Grant Select on testdb.* to [email protected]; --DBAs can query the tables in TestDB.

3. Grant acts on a single data table:

Grant SELECT, INSERT, UPDATE, delete on testdb.orders to [email protected];

4. Grant acts on the columns in the table:

Grant Select (ID, SE, rank) on testdb.apache_log to [email protected];

5. Grant acts on stored procedures, functions:

Grant execute on procedure testdb.pr_add to ' dba ' @ ' localhost '

Grant execute on function testdb.fn_add to ' dba ' @ ' localhost '

Note: Be sure to refresh the service after modifying the permissions, or restart the service, refresh the service by: Flush privileges.

The way Mysql is used, pretty full enough

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.