mysql 权限管理


mysql> select * from user where host='localhost' and user='admin' \G  

*************************** 1. row ***************************
                 Host: localhost
                 User: admin
             Password: *163F13FDA031E4FED397E030174D16EC1******
          Select_priv: Y
          Insert_priv: Y
          Update_priv: Y
          Delete_priv: Y
          Create_priv: Y
            Drop_priv: Y
          Reload_priv: Y
        Shutdown_priv: Y
         Process_priv: Y
            File_priv: Y
           Grant_priv: N
      References_priv: Y
           Index_priv: Y
           Alter_priv: Y
         Show_db_priv: Y
           Super_priv: Y
Create_tmp_table_priv: Y
     Lock_tables_priv: Y
         Execute_priv: Y
      Repl_slave_priv: Y
     Repl_client_priv: Y
     Create_view_priv: Y
       Show_view_priv: Y
  Create_routine_priv: Y
   Alter_routine_priv: Y
     Create_user_priv: Y
           Event_priv: Y
         Trigger_priv: Y
             ssl_type: 
           ssl_cipher: 
          x509_issuer: 
         x509_subject: 
        max_questions: 0
          max_updates: 0
      max_connections: 0

 max_user_connections: 0


其中,Host字段表示,哪个ip段可以访问mysql,如果没有配置,是范围不了的

user:要结合Host使用。 在哪个ip段的这个用户的权限

Password:是该ip段的这个用户的密码

剩下的是  权限以及其他属性


GRANT ALL ON *.* TO 'admin'@'localhost';

当执行第一条语句的时候,admin用户在 localhost下不需要密码就可以登录

这个时候,select user表的结果是

Host: localhost
User: admin
Password: 


SET PASSWORD FOR 'admin'@'localhost' = PASSWORD('123456');
当设置密码后,Password字段,多了个加密的密码



GRANT ALL ON *.* TO 'admin'@'192.168.%';
SET PASSWORD FOR 'admin'@'192.168.%' = PASSWORD('123456');



You need not create an account specifically for replication. However, you should be aware that the user name and password will be stored in plain text within the master.info file (see Section 16.2.2.2, “Slave Status Logs”). Therefore, you may want to create a separate account that has privileges only for the replication process, to minimize the possibility of compromise to other accounts.

To create a new acccount, use CREATE USER. To grant this account the privileges required for replication, use theGRANT statement. If you create an account solely for the purposes of replication, that account needs only theREPLICATION SLAVE privilege. For example, to set up a new user, repl, that can connect for replication from any host within the mydomain.com domain, issue these statements on the master:

mysql> CREATE USER 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.mydomain.com';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值