Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ MySQL Authorized a recovered     - Merge Sort (Programming)

- C language print various graphic (Programming)

- Oracle Standby Redo Log experiment (Database)

- Linux Security Module (LSM) Introduction (Linux)

- Different between Linux file path and the windows (Linux)

- grep, egrep and regular expressions (Linux)

- Puppet 3.5 Source package Installation and Configuration (Server)

- A key installation Gitlab 7 on RHEL6.4 and Setup Mail TX (Linux)

- Linux usage in echo (Linux)

- Oracle 11g R2 RAC RMAN backup script example (Database)

- Use IF NOT EXISTS create a data table (Database)

- Configuring Eclipse Note Templates (Linux)

- OpenGL ES 3.0 vertex buffer (Programming)

- Installation through the network Debian 7 (Wheezy) (Linux)

- Remote database using RMAN recovery test (RAC return to single-instance database) (Database)

- MongoDB start under Linux (Database)

- Python decorators to learn and practice the actual usage scenarios (Programming)

- Modify MySQL character encoding under Linux (Database)

- MariaDB 10.0.X, the dynamic column support JSON format to obtain data (Database)

- IPTABLES configuration steps under Linux (Linux)

 
         
  MySQL Authorized a recovered
     
  Add Date : 2018-11-21      
         
         
         
  Create Test Table
create table t1 (id int);
 create table t2 (id int);
 create table t3 (id int);
 create table t4 (msg varchar (100));

If the authorization when FIG provincial thing, authorize the use of wildcards.
. Grant select, insert, update, delete on mvbox * to 'xx' @ 'localhost' identified by 'xx';

If you need to recycle a certain table permissions when you will have trouble.
mysql> show grants for xx @ 'localhost';
 + ------------------------------------------------- -------------------------------------------------- -------- +
 | Grants for xx @ localhost |
 + ------------------------------------------------- -------------------------------------------------- -------- +
 |. GRANT USAGE ON * * TO 'xx' @ 'localhost' IDENTIFIED BY PASSWORD '* B30134364A2D14319904C2C807363CF2C81ABD5B' |
 |. GRANT SELECT, INSERT, UPDATE, DELETE ON `mvbox` * TO 'xx' @ 'localhost' |
 + ------------------------------------------------- -------------------------------------------------- -------- +
 2 rows in set (0.00 sec)

 mysql> revoke insert on mvbox.t1 from xx @ 'localhost';
ERROR 1147 (42000): There is no such grant defined for user 'xx' on host 'localhost' on table 't1'
 mysql>

Because authorization is a wildcard use, recycling also requires the use of wildcards.

If you need the t1 table insert permissions, you can use the following triggers.

delimiter //
 
CREATE TRIGGER tri1 BEFORE INSERT ON t1 FOR EACH ROW

BEGIN

    DECLARE msg varchar (100);

    DECLARE cu varchar (40);

    set cu = (select substring_index ((select user ()), '@', 1));

    IF cu = 'xx' THEN

            set msg = concat (cu, "You have no right to operate data please connect DBAs!");

            SIGNAL SQLSTATE 'HY000' SET MESSAGE_TEXT = msg;

    END IF;

END;

//

delimiter;
In this case, log on to xx, insert t1 table is given as follows
mysql> insert into t1 values ​​(10);
 ERROR 1644 (HY000): xx You have no right to operate data please connect DBAs!

 


It should be noted that current_user, user function, when the trigger is called, the returned content is not the same.
Delete the original trigger, trigger a new test


drop trigger tri1;
 
delimiter //

CREATE TRIGGER `tri2` BEFORE INSERT ON` t1` FOR EACH ROW

BEGIN

    insert into t4 values ​​(concat (current_user (), ',', user (), ',', session_user ()));

END;

//

delimiter;
Use xx users log in, run the following command
mysql> insert into t1 values ​​(10);
 Query OK, 1 row affected (0.00 sec)

 mysql> select * from t4;
 + ------------------------------------------ +
 | Msg |
 + ------------------------------------------ +
 | Root @ localhost, xx @ localhost, xx @ localhost |
 + ------------------------------------------ +
 1 row in set (0.00 sec)

Can be found in the trigger, current_user () returns the trigger definer.
The user (), session_user () is connected to the user.

mysql>
     
         
         
         
  More:      
 
- Use Oracle Data Guard to complete cross-platform database migration cases (Database)
- shell script error dirname: invalid option - b (Database)
- SSH without password (Linux)
- Oracle inverted reverse function (Database)
- MySQL Installation Troubleshooting (Database)
- Embedded Linux to solve the problem in the time zone (Linux)
- MongoDB upgrade from 2.4.9 to 2.6.0 and PHP record of mongo extension upgrade from 1.4.5 to 1.5.1 (Database)
- CentOS 6.6 install JDK7 (Linux)
- 10 Best Swift Tutorial examples (Programming)
- Ten best plug surge Emacs Productivity (Linux)
- Nodejs mysql pool Example (Programming)
- Docker ecosystem security is gradually maturing (Server)
- The sublime into IDE (Linux)
- DRBD installation configuration, working principle and Recovery (Server)
- Eclipse 3.7.2 can not start solving under Ubuntu 14.04 (Linux)
- Linux awk text analysis tool (Linux)
- Linux protobuf-c (Linux)
- How to use the character in C ++ without pressing the Enter key to enter the Show (Programming)
- Java transient keyword (Programming)
- Linux install the Java Runtime Environment and the output Hello World under (CentOS) (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.