Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysql5.7 forgot how to change the root password

Shulou Source: shulou.com Published: 2022-06-01 18:54:41 12月04日 Update

The main purpose of this article is to tell you briefly how to change mysql5.7 's forgotten root password. You can check the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here, so let's go straight to the topic. I hope that mysql5.7 forgets how to change your root password. This article can bring you some practical help.

1. Stop the mysql service

/ etc/init.d/mysqld stop

(permanent address of this article: http://woymk.blog.51cto.com/10000269/1916742)

Restart the service

/ usr/local/mysql/bin/mysqld_safe-skip-grant-tables-skip-networking&

Note:-- the skip-networking parameter can block remote client connections and increase security

Or

Vi / etc/my.cnf

Add the following two lines in [mysqld]

[mysqld]

Skip-grant-tables

Skip-networking

Restart the service after saving

/ etc/init.d/mysqld start

After changing the password, you must remember to change it back.

two。 Modify the password

/ usr/local/mysql/bin/mysql-uroot

Mysql > FLUSH PRIVILEGES

MySQL 5.7.6 and later do this:

Mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY' MyNewPass'

MySQL 5.7.5 and previous versions perform this:

Mysql > SET PASSWORD FOR 'root'@'localhost' = PASSWORD (' MyNewPass')

Then quit mysql

Mysql > quit

Note that if ALTER USER execution fails, try the following command:

UPDATE mysql.user SET authentication_string = PASSWORD ('MyNewPass')

WHERE User = 'root' AND Host =' localhost'

FLUSH PRIVILEGES

3. Restart the service

/ etc/init.d/mysqld restart

/ usr/local/mysql/bin/mysql-uroot-p

At this point, you can log in with the new password you just changed.

Mysql5.7 forgot how to change the root password to tell you here, for other related issues you want to know can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

Tags: Password service specialty version industry security expertise subject book content parameter command address security actual customer client news terminology section Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft NVidia MySQL macOS Shulou Information