当前位置:网站首页>mysql 修改密码和忘记密码操作
mysql 修改密码和忘记密码操作
2022-08-09 09:29:00 【潇湘梦】
忘记密码比较麻烦,太简单被攻破,太复杂记不住 嗨。。。。
重置密码的第一步就是跳过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('[email protected]') where user='root';
flush privileges; #立即生效
drop user [email protected]'%';
禁止、允许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 [email protected]'%';
SHOW DATABASES;
drop DATABASE please_read_me_vvv;
查看用户
select User,authentication_string,Host from user;
grant all privileges oncloudservicedb.* to 'cloudservice'@'%';
边栏推荐
猜你喜欢
随机推荐
.ts 音频文件转换成 .mp3 文件
5.Set接口与实现类
通用的测试用例编写大全(登录测试/web测试等)
What does the test plan include?What is the purpose and meaning?
迭代
Ontology Development Diary 05-Strive to Understand SWRL (Part 2)
测试计划包括哪些内容?目的和意义是什么?
try catch 对性能影响
本体开发日记05-努力理解SWRL(下)
3. Practice the Thread
4.泛型和工具类
搭建Tigase进行二次开发
RPC服务远程漏洞
Global 19 Google Satellite Map Free View Download
Tigase插件编写——注册用户批量查询
【机器学习】网络爬虫实战详解
[Machine Learning] Basics of Data Science - Basic Practice of Machine Learning (2)
Teach you how to get a 0.1-meter high-precision satellite map for free
Go-goroutine 的那些事
全网最全的软件测试基础知识整理(新手入门必学)






