💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
密码管理 1、执行create命令创建用户,密码: `create user 'test5'@'localhost' identified by '123456' ` 2、修改用户密码的方式: (1) `mysql > alter user 'test5'@'localhost' identified by '1234567';` (2) `mysql > set password for 'test5'@'localhost'=PASSWORD('12345678');` (3) shell > mysqladmin -u 用户名 -p旧密码 password 新密码   shell > mysqladmin -u root -h host_name password "new_password" ##没有设置过密码可用这条命令 3、修改本身用户密码: ~~~ mysql > alter user user() identified by '1234567'; mysql > set password = password('1234567'); ~~~ 4、设置密码过期策略 (1)、default_password_lifetime=180 设置180天过期(在my.cnf中定义) default_password_lifetime=0 设置密码不过期 (2)、如果为每个用户设置密码过期策略,则会覆盖上述系统参数 ~~~ `alter user 'test'@'localhost' password expire interval 90 day;` alter user 'test'@'localhost' password expire never; ##密码不过期 alter user 'test'@'localhost' password expire default;###默认过期策略,永不过期 ~~~ (3)、手动强制某个用户密码过期 `alter user 'test'@'localhost' password expire;` ~~~ 示例: mysql> alter user 'root'@'localhost' password expire; Query OK, 0 rows affected (0.00 sec) 告警信息: mysql> select 1; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql> alter user user() identified by '123456'; ###重置密码 ~~~