mysql 修改密码和忘记密码操作

忘记密码比较麻烦,太简单被攻破,太复杂记不住 嗨。。。。


重置密码的第一步就是跳过MySQL的密码认证过程,方法如下:


#vim /etc/my.cnf(注:windows下修改的是my.ini)

在文档内搜索mysqld定位到[mysqld]文本段:
/mysqld(在vim编辑状态下直接输入该命令可搜索文本内容)

在[mysqld]后面任意一行添加“skip-grant-tables”用来跳过密码验证的过程,如下图所示:

保存文档并退出



/etc/init.d/mysql restart  (有些用户可能需要使用/etc/init.d/mysqld restart)


msyql 

user mysql


update mysql.user set authentication_string=password('tanli!QAZ@WSX') where user='root';

flush privileges;  #立即生效

drop user mysqlbackups@'%';


 禁止、允许MySQL root用户远程访问权限

关闭MySQL root用户远程访问权限:

use mysql;

update user set host = "localhost" where user = "root" and host = "%";

flush privileges;

打开MySQL root用户的远程访问权限:

use mysql;

update user set host = "%" where user = "root";

flush privileges;

update user set host = '%' where user = 'cloudservice';




--创建名称为“testdb”数据库,并设定编码集为utf8
CREATE DATABASE IF NOT EXISTS testdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

--创建了一个名为:test 密码为:1234 的用户
 create user 'test'@'localhost' identified by '1234';


--授予用户test通过外网IP对数据库“testdb”的全部权限
grant all privileges on 'testdb'.* to 'test'@'%' identified by '1234';  


CREATE DATABASE IF NOT EXISTS cloudservicedb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

create user 'cloudservice'@'localhost' identified by '123456789';

grant all privileges on 'cloudservicedb'.* to 'cloudservice'@'%' identified by '123456789';

grant create,alter,drop,select,insert,update,delete on cloudservicedb.* to cloudservice@'%';	 



SHOW DATABASES;

drop  DATABASE  please_read_me_vvv;

查看用户
 select User,authentication_string,Host from user;


grant all privileges oncloudservicedb.*  to 'cloudservice'@'%';










  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值