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 clear the MYSQL password in linux

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

Share

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

Today, I will talk to you about how to clear the MYSQL password in linux, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

1. Log in to the system as a root user first

two。 Shut down the MYSQL service or process: service d stop / killall mysqld

3. Privileged startup MYSQL: / usr/local/mysql/bin/mysqld_safe-- skip-grant-tables & or mysqld_safe-- skip-grant-tables-- skip-networking & (Note: parameter-- skip-grant-tables: skip authorization table;-- skip-networking: do not listen for TCP/IP connections)

4. Then you can enter MySQL:mysql-u root-p without a password (enter directly when you are required to enter a password)

Mysql > use mysql

Mysql > update user set password=password ('new pw') where user='root' (Note:' new pw' is your new password, others copy it.

Another way to write: update mysql.user set password=password ('new pw') where user='root'

5. Update:

Mysql > flush privileges

Mysql > quit

6. End the MYSQL process you just started: killall mysqld or killall-9 mysqld.

7. Start MYSQL: service mysql start normally

8. Log in with 'new pw': mysql-u root-p.

OK.

> > you can also do this at the same time:

First, modify the login settings for MySQL:

# vi / etc/my.cnf

Add a sentence to the paragraph of [mysqld]: skip-grant-tables

For example:

[mysqld]

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock

Skip-grant-tables

Save and exit vi.

Then, restart mysqld and go in to change the password, as in the above method

Finally, change the login settings for MySQL back:

# vi / etc/my.cnf

Delete the skip-grant-tables just added in the paragraph of [mysqld]

Save and exit vi.

Log in to MYSQL again, just like OK.

After reading the above, do you have any further understanding of how to clear the MYSQL password in linux? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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