Linux 破解mysql密码
mysql忘记密码怎么办
[root@master ~]# mysql -uroot -pHuawei123123$
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@master ~]# 
1.更改配置文件
在[mysqld]下增加一条  skip-grant-tables

重启mysql
systemctl  restart  mysqld
2.进入mysql
[root@master ~]# mysql -uroot
选择数据库
use  mysql
显示所有表
show  tables;
查看user表
select * from user\G

可以看到密码在最下面
3.更新数据库信息

update user set authentication_string=password('Passwd123$') where Host='localhost' and User='root';
4.删除skip-grant-tables并重启服务

systemctl restart mysqld
5.用新密码登录

mysql -uroot -pPasswd123$
成功
重装mysql要注意
systemctl stop mariadb
删除配置文件
rm -rf /etc/my.cnf.d   /etc/my.cof
[root@localhost ~]# rm -rf /var/lib/mysql/* #删除mysql目录下所以文件
[root@localhost ~]# rm -rf /var/log/mysqld.log #删除日志
  yum -y remove mariadb mariadb-server
角色赋权以及windows测试登录
MariaDB [(none)]> create user 'xxx'@'%' identified by 'xxxx';
MariaDB [(none)]> grant all on kodbox.* to 'supermao12'@'%';
windows登录一定得按照这个格式 (kodbox为数据库)
C:\Users\25671>mysql -u supermao12 -pxxxxx -h supermao.top kodbox
注意p和密码之间没有空格
 
                    
                 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号