mysql绕过密码登录_MySQL账户、密码修改,跳过权限强制登录

MYSQL账户、密码修改

cmd窗口下登录mysql

登录:mysql -u账户名 -p

查看mysql库中现有的账户:select user from mysql.user;

连接到mysql库:use mysql;

mysql数据库中有一个user表,表中有用户名user、权限host、密码authentication_string等字段。

修改账户名:update user set user = ‘xxxx’ where user = ‘root’;

修改密码(旧版mysql中user表有password字段,新版用authentication_string字段代替原来的password,修改密码还是用password()函数):

update user set authentication_string=password(‘xxxxx’) where user=’root’ and host=’localhost’;

更新系统权限:flush privileges;

新版8.0MySQL密码修改

alter user ‘root’@’localhost’ identified by ‘baijin’;

无需刷新权限,即可使用新密码登录。

创建新账户,为新账户授予权限

使用root账户登录mysql,创建新账户:

格式:create user ‘username’@’host’ identified by ‘password’;

eg:create user ‘fengbao’@’host’ identified by ‘123’;

为新账户授权

首先为新账户创建一个数据库testDB:create database testDB;

为新账户授予最高权限:grant all privileges on testDB.* to fengbao@localhost identified by ‘123’;

更新系统权限:flush privileges;

退出后,可以用新账户登录mysql

删除账户:delete from user where user=’fengbao’;

更新系统权限:flush privileges;

忘记账户或者密码时,跳过权限,强制登录mysql

以管理员身份登录cmd,停止mysql服务:net stop mysql

进入mysql安装目录bin文件下,进入mysql的安全模式:

mysqld -nt –skip-grant-tables

重新打开一个cmd窗口,输入mysql -uroot -p,使用空密码登录mysql

查看账户:select user from mysql.user;

修改密码:

update user set authentication_string=password(‘xxx’) where user=’账户名’ and host=’localhost’;

更新权限:flush privileges;

退出:quit

调出任务管理器,结束mysql -nt.exe安全模式进程。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值