Home Database Mysql Tutorial 讲解几种破解MySQL数据库root密码的方法_MySQL

讲解几种破解MySQL数据库root密码的方法_MySQL

Jun 01, 2016 pm 01:47 PM
password

bitsCN.com

几种破解mysql root密码的几种方法:


方法一


使用phpmyadmin,这是最简单的了,修改mysql库的user表,不过别忘了使用PASSWORD函数。


方法二


使用mysqladmin,这是前面声明的一个特例。


mysqladmin -u root -p password mypasswd


输入这个命令后,需要输入root的原密码,然后root的密码将改为mypasswd。


把命令里的root改为你的用户名,你就可以改你自己的密码了。


当然如果你的mysqladmin连接不上mysql server,或者你没有办法执行mysqladmin,那么这种方法就是无效的,而且mysqladmin无法把密码清空。


下面的方法都在mysql提示符下使用,且必须有mysql的root权限:


方法三


mysql> Insert INTO mysql.user (Host,User,Password)


VALUES(’%’,’jeffrey’,PASSWORD(’biscuit’));


mysql> FLUSH PRIVILEGES


确切地说这是在增加一个用户,用户名为jeffrey,密码为biscuit。


在《mysql中文参考手册》里有这个例子:


注意要使用PASSWORD函数,然后还要使用FLUSH PRIVILEGES。


方法四


和方法三一样,只是使用了REPLACE语句


mysql> REPLACE INTO mysql.user (Host,User,Password)


VALUES(’%’,’jeffrey’,PASSWORD(’biscuit’));


mysql> FLUSH PRIVILEGES


方法五


使用SET PASSWORD语句,


mysql> SET PASSWORD FOR " = PASSWORD(’biscuit’);


拟也必须使用PASSWORD()函数,但是不需要使用FLUSH PRIVILEGES。


方法六


使用GRANT ... IDENTIFIED BY语句


mysql> GRANT USAGE ON *.* TO " IDENTIFIED BY ’biscuit’;


这里PASSWORD()函数是不必要的,也不需要使用FLUSH PRIVILEGES。


注意: PASSWORD() [不是]以在Unix口令加密的同样方法施行口令加密。


MySQL 忘记口令的解决办法


如果 MySQL 正在运行,首先杀之: killall -TERM mysqld。


启动 MySQL :bin/safe_mysqld --skip-grant-tables &


就可以不需要密码就进入 MySQL 了。


然后就是


>use mysql


>update user set password=password("new_pass") where user="root";


>flush privileges;


重新杀 MySQL ,用正常方法启动 MySQL 。


mysql密码清空


Windows:


1.用系统管理员登陆系统。


2.停止MySQL的服务。


3.进入命令窗口,然后进入MySQL的安装目录,比如我的安装目录是c:mysql,进入C:mysqlin


4.跳过权限检查启动MySQL,


c:mysqlin>mysqld-nt --skip-grant-tables


5.重新打开一个窗口,进入c:mysqlin目录,设置root的新密码


c:mysqlin>mysqladmin -u root flush-privileges password "newpassword"


c:mysqlin>mysqladmin -u root -p shutdown


将newpassword替换为你要用的root的密码,第二个命令会提示你输入新密码,重复第一个命令输入的密码。


6.停止MySQL Server,用正常模式启动Mysql


7.你可以用新的密码链接到Mysql了。


Unix&Linux:


1.用root或者运行mysqld的用户登录系统;


2.利用kill命令结束掉mysqld的进程;


3.使用--skip-grant-tables参数启动MySQL Server


shell>mysqld_safe --skip-grant-tables &


4.为设置新密码


shell>mysqladmin -u root flush-privileges password "newpassword"


5.重启MySQL Server


mysql修改密码


mysql修改,可在mysql命令行执行如下:


mysql -u root mysql


mysql> Update user SET password=PASSWORD("new password") Where user=’name’;


mysql> FLUSH PRIVILEGES;


mysql> QUIT


教你如何将MySQL数据库的密码恢复


因为MySQL密码存储于数据库mysql中的user表中,所以只需要将我windows 2003下的MySQL中的user表拷贝过来覆盖掉就行了。


在c:mysqldatamysql(linux 则一般在/var/lib/mysql/mysql/)目录下有三个user表相关文件user.frm、user.MYD、user.MYI


user.frm //user表样式文件


user.MYD //user表数据文件


user.MYI //user表索引文件


为保险起见,三个都拷贝过来,不过其实如果之前在要恢复的那个MySQL上没有更改过表结构的话,只要拷贝user.MYD就行了


然后


#. /etc/rc.d/init.d/mysql stop


#. /etc/rc.d/init.d/mysql start


#mysql -u root -p XXXXXX


好了,可以用windows 2003下mysql密码登陆了


mysql>use mysql


mysql>update user set Password=PASSWORD(’xxxxxx’) where User=’root’;


这时候会出错,提示user表只有读权限


我分析了一下原因,只这样的,因为user.*文件的权限分配是windows 2003下的,在windows 2003下我ls -l一看权限是666


在linux下我一看,拷过来后权限变成了600(其实正常情况下600就行了,只不过这里的文件属主不是mysql,拷过来后的属主变为了root,所以会出现权限不够,这时候如果你改成权限666则可以了,当然这样不好,没有解决问题的实质),在/var/lib/mysql/mysql/下ls -l看了一下再


#chown -R mysql:mysql user.*


#chmod 600 user.*


//OK,DONE


重起一下MYSQL


重新连接


mysql>use mysql


mysql>update user set Password=PASSWORD(’xxxxxx’) where User=’root’;


mysql>FLUSH PRIVILEGES;


有一点值得注意:如果你windows 下mysql如果是默认配置的话,注意要还要执行


mysql>delete from user where User=’’;


mysql>delete from user where Host=’%’;


mysql>FLUSH PRIVILEGES;


好了,到这里恢复密码过程就完成了


这个方法么就是有点局限性,你必须也具备另外的user表文件


其他还有几种方法


其它方法一(这个是网上流传较广的方法,mysql中文参考手册上的)


1. 向mysqld server 发送kill命令关掉mysqld server(不是 kill -9),存放进程ID的文件通常在MYSQL的数据库所在的目录中。


killall -TERM mysqld


你必须是UNIX的root用户或者是你所运行的SERVER上的同等用户,才能执行这个操作。


2. 使用`--skip-grant-tables’ 参数来启动 mysqld。 LINUX下:


/usr/bin/safe_mysqld --skip-grant-tables , windows下c:mysqlinmysqld --skip-grant-tables


3. 然后无密码登录到mysqld server ,


>use mysql


>update user set password=password("new_pass") where user="root";


>flush privileges;


你也可以这样做:


mysqladmin -h hostname -u user password ’new password’’


4. 载入权限表:

mysqladmin -h hostname flush-privileges’


或者使用 SQL 命令


FLUSH PRIVILEGES’


5.killall -TERM mysqld


6.用新密码登陆


其它方法二


直接用十六进制编辑器编辑user.MYD文件


不过这个里面我要说明一点,我这里编辑的时候发现个问题,加密的密码串有些是连续存储的,有些的最后两位被切开了,后两位存储在后面其他地方.这一点我还没想明白.还有注意一点就是编辑的是加密过的密码串,也就是说你还是需要另外有user表文件。这种方法和我最上面介绍的方法的区别在于,这种方法直接编辑linux下的user表文件,就不需要重新改文件属主和权限了


修正一下:我在Windows下的实际操作如下


1.关闭正在运行的MySQL。


2.打开DOS窗口,转到mysqlin目录。


3.输入


mysqld-nt --skip-grant-tables


回车。如果没有出现提示信息,那就对了。


4.再开一个DOS窗口(因为刚才那个DOS窗口已经不能动了),转到mysqlin目录。


5.输入mysql回车,如果成功,将出现MySQL提示符 >


6. 连接权限数据库


>use mysql;


(>是本来就有的提示符,别忘了最后的分号)


6.改密码:


> update user set password=password("123456") where user="root"; (别忘了最后的分号)


7.刷新权限(必须的步骤)


>flush privileges;


8.退出


> q


9.注销系统,再进入,开MySQL,使用用户名root和刚才设置的新密码123456登陆。


据说可以用直接修改user表文件的方法:


关闭MySQL,Windows下打开Mysqldatamysql,有三个文件user.frm,user.MYD,user.MYI找个 bitsCN.com

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem that Windows 11 prompts you to enter the administrator username and password to continue? How to solve the problem that Windows 11 prompts you to enter the administrator username and password to continue? Apr 11, 2024 am 09:10 AM

When using Win11 system, sometimes you will encounter a prompt that requires you to enter the administrator username and password. This article will discuss how to deal with this situation. Method 1: 1. Click [Windows Logo], then press [Shift+Restart] to enter safe mode; or enter safe mode this way: click the Start menu and select Settings. Select "Update and Security"; select "Restart Now" in "Recovery"; after restarting and entering the options, select - Troubleshoot - Advanced Options - Startup Settings -&mdash

How to set router WiFi password using mobile phone (using mobile phone as tool) How to set router WiFi password using mobile phone (using mobile phone as tool) Apr 24, 2024 pm 06:04 PM

Wireless networks have become an indispensable part of people's lives in today's digital world. Protecting the security of personal wireless networks is particularly important, however. Setting a strong password is key to ensuring that your WiFi network cannot be hacked by others. To ensure your network security, this article will introduce in detail how to use your mobile phone to change the router WiFi password. 1. Open the router management page - Open the router management page in the mobile browser and enter the router's default IP address. 2. Enter the administrator username and password - To gain access, enter the correct administrator username and password in the login page. 3. Navigate to the wireless settings page - find and click to enter the wireless settings page, in the router management page. 4. Find the current Wi

Tutorial on changing wifi password on mobile phone (simple operation) Tutorial on changing wifi password on mobile phone (simple operation) Apr 26, 2024 pm 06:25 PM

Wireless networks have become an indispensable part of our lives with the rapid development of the Internet. In order to protect personal information and network security, it is very important to change your wifi password regularly, however. To help you better protect your home network security, this article will introduce you to a detailed tutorial on how to use your mobile phone to change your WiFi password. 1. Understand the importance of WiFi passwords. WiFi passwords are the first line of defense to protect personal information and network security. In the Internet age, understanding its importance can better understand why passwords need to be changed regularly. 2. Confirm that the phone is connected to wifi. First, make sure that the phone is connected to the wifi network whose password you want to change before changing the wifi password. 3. Open the phone’s settings menu and enter the phone’s settings menu.

How to use Passkey for your Microsoft account How to use Passkey for your Microsoft account Feb 19, 2024 am 11:03 AM

Passkey is a more advanced and secure way to log in and can be used with a Microsoft account. This article will guide you how to use Passkey in your Microsoft account, introduce its advantages and the differences with passwords. Before we get into the details, we emphasize that if you frequently forget your passwords or need to log in quickly, Passkey will generally be better for you. What is Passkey? How are they different from passwords? Passwords are an advanced and secure authentication method that can replace traditional password logins. Each application has a unique key, ensuring security and preventing threats like phishing. Users can confirm their identity via email and password, or use facial recognition, fingerprint or security key

Incorrect password, beware BitLocker warning Incorrect password, beware BitLocker warning Mar 26, 2024 am 09:41 AM

This article will explore how to solve the problem of wrong password, especially the need to be careful when dealing with BitLocker warnings. This warning is triggered when an incorrect password is entered multiple times in BitLocker to unlock the drive. Usually, this warning occurs because the system has a policy that limits incorrect login attempts (usually three login attempts are allowed). In this case, the user will receive an appropriate warning message. The complete warning message is as follows: The password entered is incorrect. Please note that continuously entering incorrect passwords will cause the account to be locked. This is to protect the security of your data. If you need to unlock your account, you will need to use a BitLocker recovery key. The password is incorrect, beware the BitLocker warning you receive when you log in to your computer

How to Remove Windows 10 Lock Screen Password Now How to Remove Windows 10 Lock Screen Password Now Jan 09, 2024 pm 03:33 PM

After upgrading the win101909 system, some friends may want to cancel their computer lock screen password. If you don’t know what to do, I think we can find the account options in the computer’s settings window. Let’s take a look at the specific methods. How to cancel the lock screen password in win101909: 1. First press Win+I to open the settings interface. 2. Then find the account--login option, and then set it as shown. How to cancel power-on password login in win101909: 1. Execute regedit during running to open the registry and navigate to the following path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\Cu

How to Fix 'iPhone Not Available” Message How to Fix 'iPhone Not Available” Message Sep 17, 2023 pm 09:25 PM

How does the "iPhone is not available" security feature work? The basic mechanism that triggers the "iPhone Not Available" message is rooted in the security features of the system's design, which track every incorrect passcode entry. This protection kicks into high gear from the fifth incorrect attempt to unlock the device. Once this milestone is reached, the iPhone sets a temporary lock period of one minute, during which any additional attempts to enter the passcode become futile. This lock duration is not static but follows an escalating pattern. Specifically, after the fifth password attempt, each subsequent incorrect password attempt will cause the lockout timer to be increased by one minute. For example, the sixth incorrect attempt will result in a 2 minute lockout and the seventh incorrect attempt will result in a 3 minute

What should I do if my Win10 password does not meet the password policy requirements? What to do if my computer password does not meet the policy requirements? What should I do if my Win10 password does not meet the password policy requirements? What to do if my computer password does not meet the policy requirements? Jun 25, 2024 pm 04:59 PM

In the Windows 10 system, the password policy is a set of security rules to ensure that the passwords set by users meet certain strength and complexity requirements. If the system prompts that your password does not meet the password policy requirements, it usually means that your password does not meet the requirements set by Microsoft. standards for complexity, length, or character types, so how can this be avoided? Users can directly find the password policy under the local computer policy to perform operations. Let’s take a look below. Solutions that do not comply with password policy specifications: Change the password length: According to the password policy requirements, we can try to increase the length of the password, such as changing the original 6-digit password to 8-digit or longer. Add special characters: Password policies often require special characters such as @, #, $, etc. I

See all articles