Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to recover Mysql password in Linux system

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to recover Mysql password in Linux system". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

What are the ways to recover Mysql passwords in Linux systems?

Method 1: Because Mysql passwords are stored in the user table in the database mysql, we just need to copy the user table with the known password to overwrite it.

Under Linux, there are three user table files user.frm, user.MYD, user. MYI in/var/lib/mysql/directory. They represent:

user.frm//user table style file

user.MYD//user table data file

user.MYI//user table index file

To be on the safe side, let's backup the files related to these three user tables first,

Then we copy the three files of the user table in the mysql library that know the password. At this time, we can see six user table files with ls.

At this point we just need to restart mysql service can use a known password to access Mysql database.

Restart command is: servicemysqlrestart or

/etc/init.d/mysqlrestart

Now we can access Mysql database with a known password.

What are the ways to recover Mysql passwords in Linux systems?

Method 2:

The first method is to recover the password under the premise of knowing another Mysql database password. If there is no such Mysql database with known password, how can we recover it? We use a method described in the Mysql Chinese reference manual, which consists of several steps:

1: Send kill command to mysqldserver to shut down mysqldserver(not kill-9), the file that stores the process ID is usually in the directory where the MYSQL database is located.

killall-TERMmysqld//you must be root on UNIX or the one you are running

SERVER equivalent user, can perform this operation.

2: Use the `--skip-grant-tables'parameter to start mysqld. (The requested URL/usr/bin/safe_mysqld--skip-grant-tables was not found on this server.

3: Then you can log in to mysqldserver without a password. At this time, the password of Mysql is the same as when it was just installed, and it is empty. Now we can change the mysql password using mysqladmin as shown in Figure 6.

4: Load the permissions table, you can use mysqladminflush-privileges to refresh the permissions table.

5: Log in with new password.

"How to recover Mysql password in Linux system" is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report