MySQL creates a read-only account

Application scenario: As long as the company has a data team, it is inevitable to let these guys touch all the database data of the whole company, but if you give them the root user directly, it is a bit dangerous, so you can only set permissions for these people, Generally speaking, they only do read operations. Since they do read operations, they only need to have select permission.

We can create users through GRANT:

GRANT SElECT ON *.* TO 'read_only_user'@'ip' IDENTIFIED BY "pa$$word"

In fact, this statement is similar to opening a remote connection. It read_only_useris the user name. If you start it, it is the ip that ipis allowed to connect to the database. Of course, if you do not restrict the ip, then write it %, and the last pa$$wordis the connection password.

Check out the permissions:

mysql> select * from user where User='read_only_user' \G;
*************************** 1. row ***************************
                  Host: %
                  User: read_only_user
           Select_priv: Y
           Insert_priv: N
           Update_priv: N
           Delete_priv: N Create_priv: N Drop_priv: N Reload_priv: N Shutdown_priv: N Process_priv: N File_priv: N Grant_priv: N References_priv: N Index_priv: N Alter_priv: N Show_db_priv: N Super_priv: N Create_tmp_table_priv: N Lock_tables_priv: N Execute_priv: N Repl_slave_priv: N Repl_client_priv: N Create_view_priv: N Show_view_priv: N Create_routine_priv: N Alter_routine_priv: N Create_user_priv: N Event_priv: N Trigger_priv: N Create_tablespace_priv: N ssl_type: ssl_cipher: x509_issuer: x509_subject: max_questions: 0 max_updates: 0 max_connections: 0 max_user_connections: 0 plugin: mysql_native_password authentication_string: *C3E77E59B58D282CF2021CD59752359091C4ED51 password_expired: N password_last_changed: 2017-05-25 00:10:37 password_lifetime: NULL account_locked: N 1 row in set (0.01 sec)

It is found that except Select_priv is Y, all others are N.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324887417&siteId=291194637