zoukankan      html  css  js  c++  java
  • MySQL用户管理(创建用户,查看用户,删除用户,修改密码)

    1)创建用户并设置密码

    mysql> create user lhd@'172.16.1.%' identified by '123';
    Query OK, 0 rows affected (0.02 sec)

    2)查看用户

    mysql> select user,host from mysql.user;
    +--------+------------------------+
    | user   | host                   |
    +--------+------------------------+
    | qiudao | 10.0.0.0/24            |
    | lhd    | 10.0.0.0/255.255.255.0 |
    | lhd    | 172.16.1.%             |
    | root   | localhost              |
    +--------+------------------------+
    4 rows in set (0.00 sec)

    3)删除用户

    mysql> drop user qiudao@'10.0.0.0/24';
    Query OK, 0 rows affected (0.00 sec)

    4)修改用户密码

    #1.方式一:命令行修改密码
    [root@db02 /service]# mysqladmin -uroot -p password
    Enter password: 123456
    New password: 123
    Confirm new password: 123
    
    #2.方式二:授权的方式修改密码
    mysql> grant all on *.* to lhd@'10.0.0.0/255.255.255.0' identified by '123456';
    Query OK, 0 rows affected (0.00 sec)
    
    #3.方式三:更新数据库密码
    mysql> update mysql.user set password=PASSWORD('123456') where user='lhd' and host='172.16.1.%';
    Query OK, 1 row affected (0.01 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    #4.方式四:直接设置密码
    mysql> set password=PASSWORD('123456');
    Query OK, 0 rows affected (0.00 sec)
  • 相关阅读:
    最大相邻差值 数学 桶排序
    hdu-1536 S-Nim SG函数
    博弈论初步(SG函数)
    hdu-5009 Paint Pearls DP+双向链表 with Map实现去重优化
    hdu-5015 233 Matrix 矩阵快速幂
    hdu-1430 魔板 康拓展开+映射优化
    hdu-1043 bfs+康拓展开hash
    康拓展开-排列的hash
    Daily Scrum 12.23
    Daily Scrum 12.22
  • 原文地址:https://www.cnblogs.com/chenlifan/p/13874812.html
Copyright © 2011-2022 走看看