zoukankan      html  css  js  c++  java
  • Users configuration

    Users configuration

    用户配置是保存在mysql_users表中

    备注:在看下面内容之前,确保理解 multi-layer configuration system

    注意:

    • 更新mysql_users表后,不执行LOAD MYSQL USERS TO RUNTIME配置不会立即生效
    • 不执行SAVE MYSQL USERS TO DISK不会持久化到磁盘

    All changes in mysql_users table do not take effect immediately, neither are persistent.
    Changes to mysql_users are to be considered as editing a config file without saving it or reloading the service.

    Copying mysql users from memory to runtime

    Admin> LOAD MYSQL USERS TO RUNTIME;

    Other alias accepted:

    • LOAD MYSQL USERS TO RUN
    • LOAD MYSQL USERS FROM MEM
    • LOAD MYSQL USERS FROM MEMORY

    Copying mysql users from memory to disk

    配置持久化到磁盘

    Admin> SAVE MYSQL USERS TO DISK;

    Other alias accepted:

    • SAVE MYSQL USERS FROM MEM
    • SAVE MYSQL USERS FROM MEMORY

    Copying mysql users from runtime to memory

    配置保存到内存

    Admin> SAVE MYSQL USERS TO MEMORY;

    Other alias accepted:

    • SAVE MYSQL USERS TO MEM
    • SAVE MYSQL USERS FROM RUN
    • SAVE MYSQL USERS FROM RUNTIME

    Copying mysql users from disk to memory

    将配置加载到内存

    Admin> LOAD MYSQL USERS TO MEMORY;

    Other alias accepted:

    • LOAD MYSQL USERS TO MEM
    • LOAD MYSQL USERS FROM DISK

    Using encrypted passwords

    ProxySQL的用户密码支持hash方式加密,具体内容详见here,在下面的例子中密码是用明文存储,这在测试环境当然是没问题的,但是不能用于生产,生产环境应该用hashed passwords

    Creating a new user

    通过往mysql_users表中插入记录来创建新用户,注意表中有几列是有默认值的。

     1 Admin> SELECT * FROM mysql_users;
     2 Empty set (0.00 sec)
     3 
     4 Admin> INSERT INTO mysql_users(username,password) VALUES ('user1','password1');
     5 Query OK, 1 row affected (0.00 sec)
     6 
     7 Admin> SELECT * FROM mysql_users;
     8 +----------+-----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
     9 | username | password  | active | use_ssl | default_hostgroup | default_schema | schema_locked | transaction_persistent | fast_forward | backend | frontend | max_connections |
    10 +----------+-----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
    11 | user1    | password1 | 1      | 0       | 0                 | NULL           | 0             | 0                      | 0            | 1       | 1        | 10000           |
    12 +----------+-----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
    13 1 row in set (0.00 sec)
    View Code

    create a new user changing several defaults

    根据下面的描述来创建用户:

    • 默认schema为detest1
    • 默认连接到的是10这个主机组的主机
    1 Admin> INSERT INTO mysql_users(username,password,default_hostgroup,default_schema) VALUES ('user2','password2',10,'dbtest1');
    2 Query OK, 1 row affected (0.00 sec)
    View Code

    Limiting the number of connections a user can create to proxysql

     1 Admin> SELECT username,max_connections FROM mysql_users;
     2 +----------+-----------------+
     3 | username | max_connections |
     4 +----------+-----------------+
     5 | user1    | 10000           |
     6 | user2    | 10000           |
     7 +----------+-----------------+
     8 2 rows in set (0.00 sec)
     9 
    10 Admin> UPDATE mysql_users SET max_connections=100 WHERE username='user2';
    11 Query OK, 1 row affected (0.01 sec)
    12 
    13 Admin> SELECT username,max_connections FROM mysql_users;
    14 +----------+-----------------+
    15 | username | max_connections |
    16 +----------+-----------------+
    17 | user1    | 10000           |
    18 | user2    | 100             |
    19 +----------+-----------------+
    20 2 rows in set (0.00 sec)
    View Code

    Disabling routing across hostgroups once a transaction has started for a specific user

    开启一个事务,根据路由规则,可能某些查询会被路由到不同的主机组,为了避免类似情况的发生,可能得启用transaction_persistent,如下例

     1 Admin> SELECT username, transaction_persistent FROM mysql_users;
     2 +----------+------------------------+
     3 | username | transaction_persistent |
     4 +----------+------------------------+
     5 | user1    | 0                      |
     6 | user2    | 0                      |
     7 +----------+------------------------+
     8 2 rows in set (0.00 sec)
     9 
    10 Admin> UPDATE mysql_users SET transaction_persistent=1 WHERE username='user2';
    11 Query OK, 1 row affected (0.00 sec)
    12 
    13 Admin> SELECT username, transaction_persistent FROM mysql_users;
    14 +----------+------------------------+
    15 | username | transaction_persistent |
    16 +----------+------------------------+
    17 | user1    | 0                      |
    18 | user2    | 1                      |
    19 +----------+------------------------+
    20 2 rows in set (0.00 sec)
    View Code

    参考文档

  • 相关阅读:
    【数论】线性模方程
    【数论】拓展欧几里得
    BZOJ1433: [ZJOI2009]假期的宿舍
    BZOJ2823: [AHOI2012]信号塔
    BZOJ1088: [SCOI2005]扫雷Mine
    BZOJ1257: [CQOI2007]余数之和sum
    BZOJ1227: [SDOI2009]虔诚的墓主人
    BZOJ1856: [Scoi2010]字符串
    BZOJ1084: [SCOI2005]最大子矩阵
    BZOJ2007: [Noi2010]海拔
  • 原文地址:https://www.cnblogs.com/geek-ace/p/9565059.html
Copyright © 2011-2022 走看看