查詢測試新用戶

  1. 列出剛剛新增的用戶 dywang 的權限,其中密碼已經加密。
    MariaDB root@(none):mysql> show grants for 'dywang'@'localhost';
    +----------------------------------------------------------------------------------+
    | Grants for dywang@localhost                                                      |
    +----------------------------------------------------------------------------------+
    | GRANT ALL PRIVILEGES ON *.* TO `dywang`@`localhost` IDENTIFIED BY PASSWORD '*06' |
    +----------------------------------------------------------------------------------+
    
    1 row in set
    Time: 0.050s
    
  2. 登出 mariadb。
    MariaDB root@(none):mysql> quit;
    Goodbye!
    
  3. 測試新增用戶 dywang,免密碼無法登入。
    [root@kvm3 ~]# mariadb -udywang
    ERROR 1045 (28000): Access denied for user 'dywang'@'localhost' (using password: NO)
    
  4. 測試新增用戶 dywang,以設定的密碼 123qwe 成功登入。
    [root@kvm3 ~]# mariadb -udywang -p123qwe
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 22
    Server version: 10.5.16-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
  5. 登出 dywang。
    MariaDB [(none)]> quit
    Goodbye