linux 修改用户密码_Mysql5.7 用户授权和密码修改

一、修改密码方法:

方法1:

set global validate_password_policy=LOW;alter user 'root'@'localhost' identified by 'test';

方法2:

set global validate_password_policy=LOW;set password for 'root'@'localhost'=password('test');

方法3:

set global validate_password_policy=LOW;update mysql.user set authentication_string=password('test') where user='root' and Host = 'localhost';

刷新权限

flush privileges;

查询用户,主机名,加密字符串

select user,host,authentication_string from mysql.user;
80ed56460437e8f4bab9f1889bb30844.png

二、用户授权

create database db_test;create user 'demo'@'%' identified by 'test';grant select,insert,delete,update on db_test.* to 'demo'@'%' ;select user,host,authentication_string from mysql.user;flush prvileges;

三、数据库开启主从后,从库为了防止别人误修改文件,开启只读模式,导致密码不能正确修改

mysql> update mysql.user set authentication_string=password('tidemo') where user='itdemo' and Host = '%';ERROR 1290 (HY000): The MySQL server is running with the --super-read-only option so it cannot execute this statementmysql> set global read_only=0;Query OK, 0 rows affected (0.00 sec)
5030999b03a5e4996a982e567d7eb1a5.png

查询是否开启只读模式 read_only 为1 ,开启

mysql> select @@read_only;+-------------+| @@read_only |+-------------+|           1 |+-------------+1 row in set (0.00 sec)

解决方法:关闭只读模式

mysql> set global read_only=0;Query OK, 0 rows affected (0.00 sec)mysql> update mysql.user set authentication_string=password('demo') where user='itdemo' and Host = '%';Query OK, 1 row affected, 1 warning (0.04 sec)Rows matched: 1  Changed: 1  Warnings: 1mysql> flush privileges;Query OK, 0 rows affected (0.01 sec)
882fb3f1877d8cb88c8b2f93ed4afa35.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值