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

The MySQL password in Linux forgot what to do

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The main purpose of this article is to introduce in detail the MySQL password in Linux and forget to do so. The sample code in this article is very detailed and has a certain reference value. Interested friends can refer to it.

What to do if you forget the MySQL password in Linux

1. Edit the / etc/my.cnf file first

Vim / etc/my.cnf

Add a line to the file to configure skip-grant-tables

For example, add to this position.

# read_rnd_buffer_size = 2m datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockskip-grant-tables

Then save and exit.

2. Restart the mysql service

Service mysqld restart

So you can skip verification and go straight to mysql.

3. Enter mysql

Mysql

4. Execute the sql statement in turn

> use mysql; change database > UPDATE user SET PASSORD = password ('new password you want to set') WHERE USER= 'root'; reset password > flush privileges; refresh MySQL's system permission related table to prevent access denied after change; or restart MySQL server > quit

Note:

If you reset the password and report an error (ERROR 1054 (42S22): Unknown column 'PASSORD' in' field list')

Then use

> update mysql.user set authentication_string=password ('the new password you want to set') where user='root'

5. Edit the / etc/my.cnf file again

Vim / etc/my.cnf

Remove skip-grant-tables configuration and save exit

6. Restart the mysql service

Service mysqld restart

At this point, you can log in with a new password!

Mysql-uroot-p

After reading the content of the appeal, do you have a general idea of what you should do when you forget the MySQL password in Linux? If you want to know more, welcome to follow the industry information channel!

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

Servers

Wechat

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

12
Report