MySQLroot用户忘记密码解决方案(安全模式,修改密码的三种方式)_MySQL
1.关闭正在运行的MySQL
2.启动MySQL的安全模式,命令如下:
mysqld --skip-grant-tables
or
mysqld-nd --skip-grant-tables
mysql -u root -p
输入密码时,直接回车
4.选择MySQL系统库
use mysql
5.查看当前系统用户root的密码
select user,host,password from user where user="root"
查看的password是经过加密的,若以后想要恢复当前密码可以先运行这条命令备份一下当前的密码
6.修改root用户的密码
update user set password=PASSWORD("your_password") where user="root"
这里是直接修改了root用户在所有登陆位置的密码,若你仅仅只想修改root在某一处的密码,可以在上一条命令中增加一个限定条件host='somewhere'
比如,下面的命令修改了root用户在本机localhost的登陆密码
update user set password=PASSWORD("your_password") where user="root" and host="localhost"
上面的操作是直接对MySQL系统库mysql进行修改,安全性较低,一旦出现误操作,成本高,难恢复,并且仅限于对mysql库有UPDATE权限的用户,MySQL本身为我们提供了一种更加简便的操作方式,在此作一下简单的介绍
修改当前登陆用户的密码,使用SELECT CURRENT_USER();可查看当前登陆用户
SET PASSWORD = PASSWORD('cleartext password');
修改bob用户在%.example.org位置上的登陆密码,注意这里的host地址%.example.org是必须要存在的
SET PASSWORD FOR 'bob'@'%.example.org' = PASSWORD('cleartext password');
当然我们也可以通过GRANT的方式修改密码
GRANT USAGE ON *.* TO 'bob'@'%.example.org' IDENTIFIED BY 'cleartext password';
关于修改密码的详细内容还是请见官方文档(5.6)
http://dev.mysql.com/doc/refman/5.6/en/set-password.html
7.刷新一下系统的权限
flush privileges;
8.关闭MySQL的安全模式,重新启动即可
注:
在第2步,启动安全模式的时候,命令行可能会一直处于挂起状态,此时Ctrl+c也不能终止运行,这时候只要通过netstat -ao查看MySQL端口是否处于监听状态,如是即代表MySQL已经进入了安全模式,出现这种现象是主要因为MySQL不提倡安全模式长时间运行使用mysql命令连接数据库时可能会出现如下错误:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
网上关于此错误的描述有很多,我们知道MySQL的默认端口是3306,当以其他端口启动服务时,使用mysql命令又没有指定对应的端口,当然就无法连接Server啦

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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

Win11 is the latest operating system launched by Microsoft. Compared with previous versions, Win11 has greatly improved the interface design and user experience. However, some users reported that they encountered the problem of being unable to install the Chinese language pack after installing Win11, which caused trouble for them to use Chinese in the system. This article will provide some solutions to the problem that Win11 cannot install the Chinese language pack to help users use Chinese smoothly. First, we need to understand why the Chinese language pack cannot be installed. Generally speaking, Win11

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

Common problems and solutions for OracleNVL function Oracle database is a widely used relational database system, and it is often necessary to deal with null values during data processing. In order to deal with the problems caused by null values, Oracle provides the NVL function to handle null values. This article will introduce common problems and solutions of NVL functions, and provide specific code examples. Question 1: Improper usage of NVL function. The basic syntax of NVL function is: NVL(expr1,default_value).

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

Common challenges faced by machine learning algorithms in C++ include memory management, multi-threading, performance optimization, and maintainability. Solutions include using smart pointers, modern threading libraries, SIMD instructions and third-party libraries, as well as following coding style guidelines and using automation tools. Practical cases show how to use the Eigen library to implement linear regression algorithms, effectively manage memory and use high-performance matrix operations.

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.

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
